Add Item To ActiveX ComboBox
My first post in this thread never appeared in my Newsreader, I assumed it
evaporated in the ether. I was a surprised to see your reply!
Set cbo = Worksheets("Sheet1").ComboBox1
or
Set cbo = Worksheets("Sheet1").OLEObjects("ComboBox1").Objec t
These both set a reference to the Combobox, thereafter there's no difference
with what you can do with 'cbo'. Either way works fine.
However the first method must always be hardcoded whereas the second can
accept a string variable, eg
Dim sMyCombo as String
sMyCombo = "ComboBox1"
set cbo = .OLEObjects(sMyCombo).Object
Typically you might have a whole bunch of code that processes different,
albeit similar, controls under given conditions. All you need do is pass the
relevant name as a string. Or maybe you might want to loop controls, etc.
Regards,
Peter T
"Daniel Jones" wrote in message
news:863ba36b-4236-4e3a-9e4d-
Peter - I spent some more time digesting your response, which is
incredibly helpful by the way. Out of curiosity, how exactly does
referencing the control through OLEObjects make it more flexible?
Is that what allows you the ability to assign entire arrays and
add items in certain locations?
Thanks Alot!
|