Hello everyone,
I have built a form in VBA for an Excel spreadsheet to search. I have 4 checkboxes, and if they are checked I want to filter on those names in a specific field. I have gotten this far. I can get one filter to work properly, but when I try to filter on 2 or more names, the array doesn't build properly and it errors out.
Here is what I have.
I have tried modifying the code to no avail. I've tried using the ReDim statement. I can't find anything that works. Thanks in advance for the help.
I have built a form in VBA for an Excel spreadsheet to search. I have 4 checkboxes, and if they are checked I want to filter on those names in a specific field. I have gotten this far. I can get one filter to work properly, but when I try to filter on 2 or more names, the array doesn't build properly and it errors out.
Here is what I have.
Code:
arrFilter = VBA.Array(chkRon, chkDave, chkTodd, chkWayne)
arrField = VBA.Array("Ron", "Dave", "Todd", "Wayne")
For i = 0 To 3
If arrFilter(i) = True Then
arrFinal = arrFinal + arrField(i)
End If
Next i
.AutoFilter Field:=2, Criteria1:=arrFinal