View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Flanagan[_2_] Bob Flanagan[_2_] is offline
external usenet poster
 
Posts: 81
Default how to test if range object target deleted

I did the following:
Sub test()
Dim cell As Range
Set cell = ActiveCell
ActiveCell.EntireRow.Delete
If cell Is Nothing Then
MsgBox "row deleted"
Else
MsgBox "cell variable is not nothing!"
End If
End Sub

The answer I got was "cell variable is not nothing!".

Question: how to check for the variable cell no longer existing? I know I
can do the following:

dim anyS as string
on error resume next
anys =""
anys = cell.address
on error goto 0
if anys ="" then
msgbox "cell is nothing"
end if

But there should be a cleaner way! Excel 2003

Bob