C
Cloudfall
I get the "Runtime error '91' " message when trying to exit a
Do...Loop. My code is as follows:
Dim cell As Range
Dim sFirst As String
:
Else
Set cell = Nothing
End If
Loop Until cell Is Nothing Or sFirst = cell.Address
I have stepped through this code. Everything works fine until I get to:
'Else', then 'Set cell = Nothing', 'End If' (the "Locals Window" tells
me that 'cell' contains 'Nothing', 'sFirst' contains "$D$4"), 'Loop
Until cell Is Nothing Or sFirst = cell.Address', and then when I try to
step to the next line it generates:
"Runtime error '91': Object variable or With block variable not set."
The code works if I comment out "Or sFirst = cell.Address" as in the
following line:
Loop Until cell Is Nothing 'Or sFirst = cell.Address
It's hard to imagine that there is something wrong with 'sFirst =
cell.Address' as the following line of code worked earlier in this
program without any problem:
"If Not cell Is Nothing And cell.Address <> sFirst Then"
I really have no idea what is going on here. Does anybody out there
know? Thank you.
Do...Loop. My code is as follows:
Dim cell As Range
Dim sFirst As String
:
Else
Set cell = Nothing
End If
Loop Until cell Is Nothing Or sFirst = cell.Address
I have stepped through this code. Everything works fine until I get to:
'Else', then 'Set cell = Nothing', 'End If' (the "Locals Window" tells
me that 'cell' contains 'Nothing', 'sFirst' contains "$D$4"), 'Loop
Until cell Is Nothing Or sFirst = cell.Address', and then when I try to
step to the next line it generates:
"Runtime error '91': Object variable or With block variable not set."
The code works if I comment out "Or sFirst = cell.Address" as in the
following line:
Loop Until cell Is Nothing 'Or sFirst = cell.Address
It's hard to imagine that there is something wrong with 'sFirst =
cell.Address' as the following line of code worked earlier in this
program without any problem:
"If Not cell Is Nothing And cell.Address <> sFirst Then"
I really have no idea what is going on here. Does anybody out there
know? Thank you.