PDA

View Full Version : Where is UserForm_Initialize() ?



JustinDevine
06-02-2006, 12:30 PM
Hi, I'm new at Excel VBA and I have been trying to add a control ( A combobox) all the references I can find talk about the UserForm_Initialize Sub, however when I instantiate controls from the toolbar and try to edit the code behind them, there is no Initialize only Click, DblClick etc. Can someone explain how I am to run code when these controls are initialized. Basically when the file is opened. I am planning to use AddItem("abc") here so taht I can populat my combo boxes. Oh if you are wondering my ultimate goal is a combobox with a list of all the sheet names that will go to the sheet using Sheet("abc").Select on selection of each sheet. If you know a much, much better way to do this plese feel free to let me know. Thanks! Have a good weekend.

-Justin

mdmackillop
06-02-2006, 12:39 PM
You'll find initialise in the dropdowns above the code screen.
Regards
MD

mvidas
06-02-2006, 01:42 PM
Justin,

Are your controls on a userform, or just a worksheet?
If it is just a worksheet, you could put the loading code in the workbook_open event, or even in the combobox_click event (so it dynamically creates the list when the user clicks there).
Comboboxes are most common on userforms, which is probably why the references you see mention that.
Matt

Norie
06-03-2006, 05:51 AM
Why not just use the built-in navigation available by right clicking on the arrows in the bottom left?

JustinDevine
06-05-2006, 06:56 AM
Its on a worksheet not a user form. Now at least I understand the difference. So what is the best way to get the same functionality when using a control directly on a worksheet?