PDA

View Full Version : Comboboxes and VBA i excel



vidar_78
10-18-2007, 01:34 AM
Hi,
I have a set of 50 comboboxes in an excel sheet, and I am trying to write values to them through a for-statement... but I can't figure out how.
I have done it by using a form in access, with this code:

For count = 1 To 50
Me("ComboBox" & count) = array(count)
Next

But of course, I can't get the Me-statement to work i an excel sheet.
Is there a way make this work in excel, or is it not possible (which nothing is by the way...:)..)

Regards
Vidar

Bob Phillips
10-18-2007, 02:09 AM
50 comboboxes? Whatever for?

Are they forms combos, or control toolbox combos?

vidar_78
10-18-2007, 02:51 AM
50 comboboxes? Whatever for?

Are they forms combos, or control toolbox combos?
Legitimate question, but it's a long story so I don't want to go in details.... :)

They are control toolbox combos (I guess), they are picked from the control toolbox at least.

I don't know the difference between controls toolbox and forms combos, so if you have a good explanation on this topic I'd be thankful....

-V

Bob Phillips
10-18-2007, 03:55 AM
I am confused by what you are trying to load (seems like single items), but this is how to access all combos in a loop



For Count = 1 To 50
MsgBox Me.OLEObjects("Combobox" & Count).Name
Next


As to forms versus control toolbox, not a great explkanation, just some info.

Forms toolbar controls are fully integrated into Excel,a nd thus are stable and intrinsic to Excel. They lack some flexibility, but are robust.

Control toolbox controls are ActiveX controls, and developed outside of Excvel (hence the oblique reference). They are more flexible, more powerful, but not really being part of Excel, they are less stable, and can cause problems in certain circumstances.