Im trying to add the code in bold to the following List Box click code, but I'm getting run time error 13, type mismatch.
Before it just referenced column H, but I would like it to reference both column H and J to find a match.
Private Sub lbUnitList_Click()
Dim ws As Worksheet
Dim rw As Range
Dim UN As Variant
Dim arrList() As Variant
Dim idx As Long
Dim I As Long
If lbUnitList.ListIndex = -1 Then Exit Sub
Set ws = Worksheets("ReturnData")
UN = (lbUnitList.List(lbUnitList.ListIndex))
With ws
For Each rw In .Range("A6", .Cells(.Rows.Count, 1).End(xlUp)).EntireRow
If rw.Cells(1, "H").Value = UN Or rw.Cells(1, "J") Then
ReDim Preserve arrList(7, idx)
arrList(0, idx) = rw.Cells(1, "A").Value
For I = 4 To 10
arrList(I - 3, idx) = rw.Cells(1, I).Value
Next I
idx = idx + 1
End If
Next rw
End With
With lbActiveItemList
.ColumnCount = 8
.ColumnWidths = "60,90,70,70,80,70,80,60"
.List = Application.Transpose(arrList)
End With
End Sub
Bookmarks