Hello everyone,
I'm trying to filter a listview based on a combobox value (value in range I) but I don't know how to write the syntax and where to add it in my code... Could you please help me on this?
Thank you !
I'm trying to filter a listview based on a combobox value (value in range I) but I don't know how to write the syntax and where to add it in my code... Could you please help me on this?
Thank you !
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim rg As Range
Dim i As Long
Dim j As Long
Set ws = ThisWorkbook.Sheets("Test")
Set rg = ws.Range("ReferenceTab")
With UserForm3.ListView1
For i = 1 To 12
.ColumnHeaders.Add , , rg.Offset(0, i - 1)
Next i
For i = 1 To 500
.ListItems.Add , , rg.Offset(i, 0)
Next i
For i = 1 To 500
For j = 1 To 11
.ListItems(i).ListSubItems.Add , , rg.Offset(i, j)
Next j
Next i
.View = lvwReport
End With
Dim v, e
With Sheets("Test").Range("I4:I500")
v = .Value
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For Each e In v
If Not .exists(e) Then .Add e, Nothing
Next
If .Count Then Me.ComboBox1.List = Application.Transpose(.Keys)
End With
End Sub