Hi. I have a VBA code where I filter a column by certain names. The names however, depending where I get them can have middle names on it whereas other just have last and first name. Example for one sheet would be Smith, John. Another could be
Smith, John Apple. In that format. How could I edit the VBA code to detect either one? I tried adding “*” in the code but it it still didn’t detect it. Also it might or might not have the space after the comma. Here is the part of the code I have right now. Works but only if it is exact. Thank you
Smith, John Apple. In that format. How could I edit the VBA code to detect either one? I tried adding “*” in the code but it it still didn’t detect it. Also it might or might not have the space after the comma. Here is the part of the code I have right now. Works but only if it is exact. Thank you
VBA Code:
Dim manone As String, mantwo As String
manone = Worksheets("Setup").Range("R3").Value
mantwo = Worksheets("Setup").Range("R4").Value
Columns("D:D").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("D1").AutoFilter Field:=1, Criteria1:= _
manone, Operator:=xlOr, Criteria2:=mantwo