Populate 2 column listbox from combobox selection

markdarb

New Member
Joined
Aug 21, 2013
Messages
1
Good evening Excel Geniuses,

I have searched high and low for an answer to this, however, I cannot seem to find anything.

I have a Userform with a combobox with 6 team options i.e. Team 1, Team 2 etc, upon selection, two listboxes are filled with corresponding data, but I want to combine this data into one 2 column'd listbox.

The coding i have to populate the 2 listboxes is:
Code:
 </SPAN>
Private Sub cboTeam_Change()
Dim cRow As Integer</SPAN>
    cRow = 2</SPAN>
    UserForm1.lbxBrokers.Clear
    UserForm1.lbxBrokerCode.Clear
   
Do Until Sheets("Database").Cells(cRow, 11).Value = Empty</SPAN>
If Sheets("Database").Cells(cRow, 11).Value = UserForm1.cboTeam.Value Then
   
    UserForm1.lbxBrokers.AddItem Sheets("Database").Cells(cRow, 12).Value
    UserForm1.lbxBrokerCode.AddItem Sheets("Database").Cells(cRow, 13).Value
   
End If
   
    cRow = cRow + 1</SPAN>
Loop</SPAN>
End Sub</SPAN>

I would appreciate any help you could give.

Thanks
Mark</SPAN>
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Will something like that do the trick [I have create a 2 columns listbox called lbxBrokersAndCode]

Private Sub cboTeam_Change()
Dim cRow As Integer
cRow = 2
UserForm1.lbxBrokersAndCode.Clear


Do Until Sheets("Database").Cells(cRow, 1).Value = Empty
If Sheets("Database").Cells(cRow, 1).Value = UserForm1.cboTeam.Value Then

With UserForm1.lbxBrokersAndCode
.AddItem Sheets("Database").Cells(cRow, 12).Value
.List(.ListCount - 1, 1) = Sheets("Database").Cells(cRow, 13).Value

End With
End If

cRow = cRow + 1
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,946
Members
449,480
Latest member
yesitisasport

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