I will like to add an If
criteria when Last name
is not found. If it is found then keep filter with criteria.
Sub Test()
Dim PnrName As String
Dim Firstrow As Long
Dim Lastrow As Long
Dim Fltrrng As Range
Firstrow = Range("B:B").Find("*", After:=Range("I1")).Row
Lastrow = Range("A:A").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
PnrName = InputBox("Please Enter Last Name")
Set Fltrrng = ActiveSheet.Range("$I$" & Firstrow & ":$I$" & Lastrow)
Fltrrng.AutoFilter Field:=9, Criteria1:="=" & PnrName & "*", Operator:=xlAnd
'**If **PnrName is found keep filter**
'Else
'MsgBox "Last Name does not exist, Please Re-Enter Last Name"
'End If**
End Sub