Global variable

  • Thread starter Thread starter dhstein
  • Start date Start date
D

dhstein

I want to set a variable in a Workbook open event and then refer to it in
another module. I tried to set a Public variable in the Workbook code but
then the module doesn't recognize it. Any help is appreciated.
 
Put the variable in a General/standard/normal module.

Public MyVar as Variant '????

Then in the ThisWorkbook module:

Option Explicit
sub workbook_open()
myvar = "what ever you want"
end sub
 
Thanks Dave.

Dave Peterson said:
Put the variable in a General/standard/normal module.

Public MyVar as Variant '????

Then in the ThisWorkbook module:

Option Explicit
sub workbook_open()
myvar = "what ever you want"
end sub
 
Back
Top