Hi all
This is my first post and I have very limited knowledge with vba coding.
I picked up the below coding to populate a listbox with data from a worksheet based on what was selected from a combobox (using RowSource). The problem is the listbox is only displaying one row, which I assume means its not looping to check more rows.
Any help would be greatly appreciated.
Cheers
PrivateSub ComboBox1_Change() Dim rngToSearch As Range
Dim rngToFind As Range
Dim valToFind As Variant
Dim arrClearList()
valToFind = ComboBox1.Value
With Worksheets("Sheet1")
Set rngToSearch = .Columns("A")
End With
Set rngToFind = rngToSearch.Find(what:=valToFind, _
LookIn:=xlFormulas, _
Lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rngToFind Is Nothing Then
ListBox1.AddItem
With ListBox1
.List(.ListCount - 1, 0) = rngToFind.Value 'Status Col A
.List(.ListCount - 1, 1) = rngToFind.Offset(0, 1).Value 'Date Col B
.List(.ListCount - 1, 2) = rngToFind.Offset(0, 3).Value 'ID Col D
.List(.ListCount - 1, 3) = rngToFind.Offset(0, 19).Value 'Ref Col T
End With
Else
MsgBox "No Incidents with a " & valToFind & " Status."
End If
End Sub
Bookmarks