• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Populate combobox2 from combobox1 value search.

IPBR21054

New Member
Please can you help.
Userform has two comboboxes 1 & 2
The user will select a value in the Combobox1 drop down.
Combobox2 should be populated with values after a simple search is done on worksheet like this.

Combobox1 selected value = Fred
Combobox2 should search the worksheet called Summary in column A for the value Fred & then take the value from column J & this should be what is populated in combobox2
Search to continue down my sheet to last row with values.
Selecting combobox2 drop down should now have values ready for the users next selection.

Thank you.
 
Use the ComboBox1_Change event to search column A and fill ComboBox2 with matching values from column J.


Example:
Code:
Private Sub ComboBox1_Change()
Dim ws As Worksheet
Dim lastRow As Long, i As Long
Set ws = ThisWorkbook.Worksheets("Summary")
ComboBox2.Clear
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow 'skip header if needed
If ws.Cells(i, "A").Value = ComboBox1.Value Then
ComboBox2.AddItem ws.Cells(i, "J").Value
End If
Next i
End Sub
<<< use code - tags >>>
 
Last edited by a moderator:
Back
Top