Hi everyone,
i have the following code below when selecting an item in ComboBox1 and pressing the CommandButton it will display the result in a listbox.
The data comes from Sheet1.
There are 5 columns, and this code filters column A.
Now my problem is, I have a second ComboBox called ComboBox2.
ComboBox2 should filter column B.
I would like, that ComboBox1 and ComboBox2 to be working together, meaning when an item in ComboBox1 and an item in ComboBox2 are selected and the CommandButton is pressed, it will then display the filtered results in the listbox.
Private Sub CommandButton1_Click()
Dim i As Long
Me.ComboBox1.Text = StrConv(Me.ComboBox1.Text, vbProperCase)
Me.ListBox1.Clear
For i = 2 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
For x = 1 To 5
A = Len(Me.ComboBox1.Text)
If Left(Sheet1.Cells(i, x).Value, A) = Me.ComboBox1.Text And Me.ComboBox1.Text <> "" Then
Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value
For c = 1 To 5
Me.ListBox1.List(ListBox1.ListCount - 1, c) = Sheet1.Cells(i, c + 1).Value
Next c
End If
Next x
Next i
End Sub
Would you mind helping me out?
I have been working on this for 2 days already and I just can't figure it out.
Thanking in advance for any assistance you could provide.
Bookmarks