Testing for existence of range

  • Thread starter Thread starter David
  • Start date Start date
D

David

Greetings,
TIA for any help
In the sub below, how can i test for the existence of the
Range referred to in rng
<rng is nothing> seems to be the wrong idea.
Sub Test()
Dim rng As Range
Set rng = Range("A1, A4, A6, A8")
rng.EntireRow.Select
Selection.Delete
MsgBox rng Is Nothing ' returns 'False'
End Sub
 
Not exactly sure of your question.
If you change the line of you code

Msgbox rng is nothing

to:
Set rng = Nothing

then the code is good.

Your question - how do I test for the existence of the Range
"rng" It exists when you create it with your Set statement.

Maybe your question is how do I check for the values in the rng?

Can you clarify
 
Thanks for your response
Let's say I start off with
<Dim rng as range
Set rng = Range("A1:A3")>
Now I delete Rows 1 to 3
The contents of rng have now disappeared
How do I test that the contents of range have dissapeared?
TIA
 
set rng = rows("1:3")
rng.Delete
on Error resume next
msgbox rng.Address
if err.number <> 0 then
msgbox "rng has been deleted"
err.clear
set rng = nothing
End if
On Error goto 0


rng is not nothing - but the object it referred to is gone.
 
Back
Top