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

My first multi column combobox 1

Status
Not open for further replies.

DrSmyth

Technical User
Jul 16, 2003
557
GB
Hi,

I've had a look around and done a few keyword searches, but I'm still a bit unsure as to how to populate a multi column combobox in excel.

Basically I've got this code for populating a single column combobox (well two single column comboboxes)

Code:
Dim c As Range
Me.ComboBox1.clear
Me.ComboBox2.clear
    For Each c In Range("PSMNAME")
        Me.ComboBox1.AddItem c.Text
        Me.ComboBox2.AddItem c.Text
    Next

But what i'm aiming to do is have two columns in each combobox. The secound column is coming from adjacent cells to the first column and i was gonna call the range PSMNAME2, or of course i could just expand the area of the first range by another column...

I realise that this is something pretty basic, but any help would be appreciated...

Also i'm interested in referring to the value in the secound colun of the combobox for later use, can anybody help here as well...

Cheers guys (and/or girls)..


Dr
 
Dim temp As Variant
With Me
temp = .Range("PSMNAME")
.ComboBox1.List = temp
.ComboBox2.List = temp
End With

combo
 
So does that mean i only need to expand the range by another column ad it'll work?
 
Just tried it combo... works like a dream... That's surprisingly simple, thanks for the help...

A Star is on it's way to you...

P.S.

How do i reference the second column of the combobox
 
Hi,
thanks for the star. Use List(row,column) or Value with preset BoundColumn, if it is fixed.
Here are some useful properties for combobox, not only multicolumn.

General properties:
List - two dimensional variant array of values,
List(row,column) - a value of list cell entry,
ListIndex - 0-biased no. of item selected, -1 for no selection,
BoundColumn - no. of column, from which Value is taken, if BoundColumn=0 then ListIndex is returned,
Value - the value for BoundColumn.

Specific for control on a worksheet, with live link:
LinkedCell - string, address or name, a cell where control's value is stored,
ListFillRange - string, address or name, a renge with control's list source.

combo
 
cheers combo, thanks for all your help... This is now working very smoothly... used the boundcolumn property in the end...

Dr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top