S
schorley
Hi
I keep getting error 91 messages (Object variable or with block
variable not set) with the below code. It happens when FoundRange comes
back as Nothing in the loop; but I'm not sure why it should come back
as Nothing. Surely it should just go back to firstFind, then the loop
should be exited?!
Thanks!
Set FoundRange = Nothing
Set FoundRange = SearchRange.Find("3600")
If Not (FoundRange Is Nothing) Then
firstFind = FoundRange.Address
Do
If Left(FoundRange.Formula, 1) = "=" Then
FoundRange.Replace What:="3600", Replacement:="GWhToGJ"
End If
Set FoundRange = SearchRange.FindNext(FoundRange)
Loop Until (FoundRange Is Nothing) Or (FoundRange.Address =
firstFind)
End If
I keep getting error 91 messages (Object variable or with block
variable not set) with the below code. It happens when FoundRange comes
back as Nothing in the loop; but I'm not sure why it should come back
as Nothing. Surely it should just go back to firstFind, then the loop
should be exited?!
Thanks!
Set FoundRange = Nothing
Set FoundRange = SearchRange.Find("3600")
If Not (FoundRange Is Nothing) Then
firstFind = FoundRange.Address
Do
If Left(FoundRange.Formula, 1) = "=" Then
FoundRange.Replace What:="3600", Replacement:="GWhToGJ"
End If
Set FoundRange = SearchRange.FindNext(FoundRange)
Loop Until (FoundRange Is Nothing) Or (FoundRange.Address =
firstFind)
End If