Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default how to test if range object target deleted

Hi Bob,

Having assigned an object to an object to a variable, deleting the object
does not remove the variable pointer from memory and so the variable will
continue to be 'not nothing'. You can confirm that with objptr(cell).
I doubt there is a cleaner way to test if the object still exists other than
to attempt to refer to one of the variable's anticipated properties under an
error handler, though I suspect there is an API approach. I think the
method you posted is just fine!

Regards,
Peter T

"Bob Flanagan" wrote in message
. ..
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking if the TARGET has been deleted Peter Rooney Excel Programming 0 February 1st 06 10:51 AM
Just a test message to be deleted Bosko Excel Worksheet Functions 1 November 3rd 05 10:06 AM
Target As Excel.Range or Target As Range Piranha[_5_] Excel Programming 2 June 3rd 05 03:49 PM
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) Kevin McCartney Excel Programming 3 April 15th 05 01:51 PM
How find if target is object in Worksheet_Change (ByVal Target As.. ?) Gunnar Johansson Excel Programming 3 July 1st 04 09:25 PM


All times are GMT +1. The time now is 01:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"