Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Testing for existence of range

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Testing for existence of range


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

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Testing for existence of range

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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Testing for existence of range

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.

--
Regards,
Tom Ogilvy

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Testing for existence of range

Tom,
Thanks for coming to my rescue once more
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
TESTING A RANGE OF CELLS Richard[_2_] New Users to Excel 3 April 1st 07 02:52 PM
TESTING A RANGE OF CELLS Richard[_2_] Excel Worksheet Functions 3 April 1st 07 02:52 PM
Testing a person's age to be within a range MH Excel Worksheet Functions 10 December 31st 06 10:04 PM
Testing for existence of a formula Bob Excel Worksheet Functions 5 November 20th 06 09:31 PM
Cell in Range Testing Function Jim C.[_2_] Excel Programming 2 July 23rd 03 06:59 PM


All times are GMT +1. The time now is 04:04 AM.

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"