using Global variable of Userform in module

A

Anoop

Hi
I'm a fresher to VBA scripting. I'm trying to assign a value to a global
variable defined in Userform' General Declaration and then using that value
in my module.

tried my way but values are blank when my Userform ends.

any suggestion would be a gr8 help. Calling all life savers..."HELP".
 
D

Dave Peterson

I think the easiest thing to do is to move the declaration to a general module.

Public MyVar as WhatEver
 
B

Bob Phillips

Set it as a property of that form.

In the form add

Public Property Get MyVar As String
myVar = your_variable_name
End Property

and in the module where you show the form, retrieve the property afterwards


With Userform1

.Show
module_variable = .MyVar
End With
 
Top