Why am I getting this error :
error 91 Block With.....
With this code:
startRow = Worksheets("Sheet1").Columns("A").Find("100", _
LookIn:=xlValues, LookAt:=xlWhole).Row
Find returns a Range object. If it is unsuccessful, it returns Nothing and therefore, trying to access the range's Row property gives an error. Try this construct:
Code:
Dim ResultRng As Range
Dim startRow As Long
Set ResultRng = Worksheets("Sheet1").Columns("A").Find _("100", LookIn:=xlValues, LookAt:=xlWhole)
If Not ResultRng Is Nothing Then startRow = ResultRng.Row
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.