Jelovac
Jelovac

Reputation: 138

How to have values from 3 columns shown in combobox VBA (active x control)

In combobox I set columnCount to 3, so when I click dropdown arrow I can see 3 columns that I need, but when I choose one row that I need, there is only value from first column shown. Combobox is wide enough for all three columns. Is there a way to see all 3 when I select my choice?

Upvotes: 1

Views: 3032

Answers (1)

Darren Bartrup-Cook
Darren Bartrup-Cook

Reputation: 19712

You need to change the ListFillRange to all the columns in your list: Sheet1!$A$5:C20

Also you need to have a single cell referenced in the LinkedCell property: Sheet1!$A$1

The bound column must be a value between 1 and 3. You can only return a single value from the list - this will be from the bound column.

Your column count must be 3.

Your column widths must be either blank or a value >0 (0 will hide the column): 85.05 pt;85.05 pt;85.05 pt

With those in place you should be seeing three columns of values in the list box - you can only return a value from one of those columns though. If you want to return more than one I'd suggest using a hidden (column width of 0) column to contain a unique identifier and then use a look-up on the sheet to fill in the blank columns.

To get to all three columns in VBA use code similar to:

Private Sub ComboBox1_Change()

    With Me.ComboBox1
        MsgBox .Column(0) & vbCr & .Column(1) & vbCr & .Column(2)
    End With

End Sub

Upvotes: 2

Related Questions