Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help! I have a workbook that

Status
Not open for further replies.

caffrinho

MIS
Mar 1, 2002
91
GB
Please help! I have a workbook that contains many comboboxes. I want to populate ALL of the comboboxes at run time with the same information for every one. I have managed to create a For Each.....Next Loop that scrolls through all of the comboboxes (Thanks Euskadi!) in turn, but i'm having problems with the syntax for populating them. So far I have.......

Dim myobject As Shape
For Each myobject In ActiveSheet.Shapes
If Left(myobject.Name, 5) = "Combo" Then


End If
Next myobject

It's the code to add items to the boxes that i can't figure out... i can do them individually using

With Combobox1
.additem strVariable
End With

Any assistance/guidance would be gratefully appreciated!

Ta..
 
Hi,
MyObject is the object you want to add the list item to...
Code:
      Dim myobject As Shape
      For Each myobject In ActiveSheet.Shapes
            If Left(myobject.Name, 5) = "Combo" Then
                With myobject 
                       .additem strVariable
                End With
           End If
     Next myobject
Hope this helps :) Skip,
metzgsk@voughtaircraft.com
 
Thanks for your input, but....

Since myobject was declared as a Shape, it doesn't recognise the '.additem' method. I've tried changing it to say:

Dim myobject as Combobox

but then i get other messages.

I'm really confused. Can anybody provide any other suggestions, Pllllleeeeeeeaaaaaaaasssssssseeeeeee!
 
Don't know what this problem may be, but here's another suggestion.

1. Create a sheet for all your lists.

2. Create each list with a heading that describes the list.

3. Name each list via the menu item - Insert/Name/Create and select the check box for 'Create name in top row'

4. Assign each Comboboxn.ListFillRange the appropriate Range Name at run time.

VOLA :) Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top