Hi friends,

I’m getting compile error ‘type mismatch’ while displaying a message at the end. Everything else is correct.

Option Explicit

Sub FindSurname()

Dim found As Range
Dim s As String
s = InputBox("enter surname to filter")
        
        Sheets("Personal").Activate
        
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        
                ActiveSheet.Range("$B$8:$AJ$5000").AutoFilter Field:=3, Criteria1:=s, Operator:=xlAnd

If s Is Not found Then ‘getting error on this line
MsgBox "Sorry! The surname " & s & " is not found!", 64
Else
 MsgBox "Congratulation! The surname " & s & " is found!", 64
 End If
 
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
End Sub
Any help will be highly appreciated.

Thanking you in anticipation.