Reputation: 51
I want to assign the "pointer" range object to a cell that should be determined through the .find method plus offsetting that found address by 3 rows via .offset method. I seem to be doing something wrong with the following code:
With Sheets("Database")
Dim pointer As Range
Set pointer = .Cells.Find("string data").Offset(3)
...
End With
I keep getting Error 91: Object variable or With block variable not set.
Thanks for your help in advance!
Upvotes: 1
Views: 27
Reputation: 3632
You get that error because .Cells.Find("string data")
returns Nothing
.
To avoid this error, you could introduce a check, like this:
Dim pointer As Range
With Sheets("Database")
If Not .Cells.Find("string data") Is Nothing Then
Set pointer = .Cells.Find("string data").Offset(3)
End If
End With
'...
Upvotes: 2