#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default Global variable

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Global variable

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



dhstein wrote:

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.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default Global variable

Thanks Dave.

"Dave Peterson" wrote:

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



dhstein wrote:

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.


--

Dave Peterson
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Global Variable dhstein Excel Discussion (Misc queries) 4 July 26th 09 05:10 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
I Need VBA Assistance for global variable question Brent E Excel Discussion (Misc queries) 1 March 1st 05 08:46 PM
Global Variable -- Excel / VBA Adam1 Chicago Excel Discussion (Misc queries) 3 February 23rd 05 12:03 AM


All times are GMT +1. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"