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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel combobox problem 1

Status
Not open for further replies.

GBall

Programmer
May 23, 2001
193
GB
Hi,
I'm tryinmg to populate a combobox I've created in a worksheet with the following code.

i = 0
Do While Not x.EOF
Sheet2.ComboBox3.Column(i, 0) = x!type_id
Sheet2.ComboBox3.Column(i, 1) = x!type_name
Sheet2.ComboBox3.Column(i, 2) = x!type_desc
i = i + 1
x.movenext
Loop
Pretty simple ?
However, the first time through I get:-
Runtime error 381
could not get the column property
Invalid property array index.

Same happens in debug if I type
?sheet2.ComboBox3.column(0) or (1)
I've defined the combobox with 3 columns.

What am I doing wrong ?


Regards,
Graham
 
Hi Graham,

A combobox has an array of columns (across) by items (down). As well as declaring the columns, you must add the items before you can reference the individual cells. I think you need to put Sheet2.Combobox3.AddItem as the first line inside your Do loop to create the row (list item) you are trying to populate.

Enjoy,
Tony
 
Thanks Tony, bang on!
Sorry for the delay in getting back - long weekend.

Regards,
Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top