variable scope

thebruins

New Member
Joined
Sep 27, 2004
Messages
13
I have an excel sheet with a commandbutton on it. Whever a user clicks it, a userform pops up with a combobox. I would like to populate the combobox by looping through a collection of items. Since I will need the items further on (for example, when the user clicks the button again), I thought it would be a good idea to read the items once from a sourcefile when the workbook opens (workbook_open), and make it a public/global collection, so all subs, functions and userforms can use the collection without having to re-read the sourcefile over and over.
so far I have created a public/global collection (in ThisWorkBook), but the userform does not recognize the variable when I try to use it. can anyone help?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Declare it in a standard module (Insert>Module) rather than the ThisWorkbook module.
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top