I am trying to create a code to search multiple table columns and also have a begins with and contains option. I created seperate option button groups for the table columns and another for begins with and contains option buttons. My problem is that I'm not sure how to get the begins with and contains option to filter to the different columns. Right now, no matter what column option I select, it will only filter my second column "Brand". The begins with/ contain options work well otherwise. I need to know how to apply begins with/contains options to columns/fields 2-4 and not just one.
Thank you for any help or suggestions.
Thank you for any help or suggestions.
VBA Code:
Private Sub txtSearchBox_Change()
If optBrand Then
ListObjects("SDS.Table").Range.AutoFilter Field:=2, Criteria1:="*" & Range("F2") & "*"
End If
If optName Then
ListObjects("SDS.Table").Range.AutoFilter Field:=3, Criteria1:=Range("F2") & "*"
End If
If optRefNo Then
ListObjects("SDS.Table").Range.AutoFilter Field:=4, Criteria1:=Range("F2") & "*"
End If
If optBeginsWith Then
ListObjects("SDS.Table").Range.AutoFilter Field:=2, Criteria1:=Range("F2") & "*"
Else
ListObjects("SDS.Table").Range.AutoFilter Field:=2, Criteria1:="*" & Range("F2") & "*"
End If
End Sub