Multiple Column Combibox

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Good Morning,

I have a combibox in a userform that I'd like to tweak. I used to pull data from just one column to display in the box, but now I was hoping to have two columns of data (separated by a space) displaying. I've written a basic piece of code below but it didn't work. Hoping someone could help.

Code:
    ComboBox2.List = [Ports!B3:B102].Value & " " & [Ports!G3:G102].Value
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
How about
Code:
        Me.ComboBox2.List = Application.Index(Sheets("Ports").Range("B3:G102").Value2, Evaluate("row(1:100)"), Array(1, 6))
 
Upvote 0
How about
Code:
        Me.ComboBox2.List = Application.Index(Sheets("Ports").Range("B3:G102").Value2, Evaluate("row(1:100)"), Array(1, 6))

Unfortunately two things happened:
1. It didn't work- Still only saw "B" column
2. It kicked an error in the combibox_change sub that highlight the code below
9-subscript out of range (and in the below code, I tried changing .value to .value2

Rich (BB code):
Private Sub ComboBox2_Change()'On Error GoTo Helper
Application.DisplayAlerts = False
Application.ScreenUpdating = False
    Sheets("Voyage Specifics").Range("C8").Value = ComboBox2.Value
    Sheets("Developer").Range("C2:D2").Value = ComboBox2.Value
Application.DisplayAlerts = True
Application.ScreenUpdating = True
'Error Clearing Code
Exit Sub
Helper:
    resp = MsgBox("We're sorry to see you've encountered an error." & vbCrLf & vbCrLf & "To proceed, we recommend you contact the Developer " & _
    "with error codes [1039] and " & "[" & Err.Number & "-" & Err.Description & "]." & vbCrLf & vbCrLf & "To attempt to patch your problem at least " & _
    "temporarily, we recommend you click [Yes] to see help directions. Would you like to continue?", vbYesNoCancel, name)
        If resp = vbYes Then
            UserForm18.Show
            'MsgBox ("Success")
        ElseIf resp = vbNo Then
            Exit Sub
        ElseIf resp = vbCancel Then
            Exit Sub
        End If
End Sub
 
Upvote 0
Have you set the combobox columncount property to 2?
 
Upvote 0
Select the combobox & then in the properties window change ColumnCount to 2
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,712
Messages
6,174,031
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top