hi,
I have a userform with 2 listbox,
ListBox1, pupulate uniqe items from column B in Sheet1, workning well,
Need help with ComboBox2.
want to fill ComboBox2 with criteria choosen fron ComboBox1
ComboBox2 should show item from column A in Sheet1
Tanks,
I have a userform with 2 listbox,
ListBox1, pupulate uniqe items from column B in Sheet1, workning well,
Need help with ComboBox2.
want to fill ComboBox2 with criteria choosen fron ComboBox1
ComboBox2 should show item from column A in Sheet1
Tanks,
VBA Code:
Private Sub UserForm_Initialize()
Dim myCollection As Collection, cell As Range
On Error Resume Next
Set myCollection = New Collection
With ComboBox1
.Clear
For Each cell In Sheets("Sheet1").Range("B2:B" & Cells(Rows.Count, 2).End(xlUp).Row)
If Len(cell) <> 0 Then
Err.Clear
myCollection.Add cell.Value, cell.Value
If Err.Number = 0 Then .AddItem cell.Value
End If
Next cell
End With
ComboBox1.ListIndex = 0
End Sub
Private Sub ComboBox1_Change()
'want to fill ComboBox2 with criteria choosen from ComboBox1
'ComboBox2 should show items from column A in Sheet1
With ComboBox2
.ColumnCount = 1
.ColumnWidths = "50"
.ColumnHeads = True
[B]'how ?[/B]
End With
End Sub