Cells.Find() Raises “Runtime Error 91: Object Variable or With Block Not Set”

If the string you’re looking for isn’t found you’ll get that error. The find function returns “Nothing” if nothing is found

    Dim r As Range

    Set r = Cells.find(What:=strCliBoa, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=True, SearchFormat:=False)

    If r Is Nothing Then
        'handle error
    Else
        'fill in your code
    End If

Leave a Comment