ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Static variables (https://www.excelbanter.com/excel-programming/306182-static-variables.html)

lynnnow[_3_]

Static variables
 
Hi,

I've got a startup Sub which has a msgbox with Y/N option. Thereafte
it shows the Application.GetOpenFilename option and the file names ar
stored to variables. Then I've got a userform that has comboboxes i
it and after this private Sub is over, I need the variables that
created in the startup Sub. These variables show Empty in the Watc
section or it shows an Out of Subscript error.

How can I keep these variables static so that I can use it later. I'v
tried using Static, but it does not help

Txs

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Static variables
 
Use a variable declared as Public at the top of a general module (and above
any subs or functions).

--
Regards,
Tom Ogilvy

"lynnnow " wrote in message
...
Hi,

I've got a startup Sub which has a msgbox with Y/N option. Thereafter
it shows the Application.GetOpenFilename option and the file names are
stored to variables. Then I've got a userform that has comboboxes in
it and after this private Sub is over, I need the variables that I
created in the startup Sub. These variables show Empty in the Watch
section or it shows an Out of Subscript error.

How can I keep these variables static so that I can use it later. I've
tried using Static, but it does not help

Txs.


---
Message posted from http://www.ExcelForum.com/




NickHK

Static variables
 
lynnnow,
You need to understand the concept of "Scope". Check Help.

NickHK

"lynnnow " wrote in message
...
Hi,

I've got a startup Sub which has a msgbox with Y/N option. Thereafter
it shows the Application.GetOpenFilename option and the file names are
stored to variables. Then I've got a userform that has comboboxes in
it and after this private Sub is over, I need the variables that I
created in the startup Sub. These variables show Empty in the Watch
section or it shows an Out of Subscript error.

How can I keep these variables static so that I can use it later. I've
tried using Static, but it does not help

Txs.


---
Message posted from http://www.ExcelForum.com/




cmart02[_2_]

Static variables
 
If all fails, you can store such variables in a worksheet. Leave it as "very
hidden" and pass the variables to the cells.


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com