Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default == How to test if a range var contains nothing

I need to check if a certain range var is nothing.
Suppose you have the following code

Dim R As Range

If R = Nothing then
End If

When I try to compile this I receive and object error in the If line. Then
how can I test if R has something. Finally IsNull and IsEmpty don´t work too.
Regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default == How to test if a range var contains nothing

Hi
one way:
If application.count(r)=0 then
'nothing
end if

--
Regards
Frank Kabel
Frankfurt, Germany


hcova wrote:
I need to check if a certain range var is nothing.
Suppose you have the following code

Dim R As Range

If R = Nothing then
End If

When I try to compile this I receive and object error in the If line.
Then how can I test if R has something. Finally IsNull and IsEmpty
don´t work too. Regards


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default == How to test if a range var contains nothing

if R is Nothing

not

if R = Nothing


"Frank Kabel" wrote:

Hi
one way:
If application.count(r)=0 then
'nothing
end if

--
Regards
Frank Kabel
Frankfurt, Germany


hcova wrote:
I need to check if a certain range var is nothing.
Suppose you have the following code

Dim R As Range

If R = Nothing then
End If

When I try to compile this I receive and object error in the If line.
Then how can I test if R has something. Finally IsNull and IsEmpty
don´t work too. Regards



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default == How to test if a range var contains nothing

Is Nothing has a specific meaning in VBA, namely that the object variable has
never been set. Is that what you are after? If so, the syntax is

If R Is Nothing Then

OTOH, if you HAVE set R to point to a range, and you want to know whether that
range is empty,

Set R = Range("A1:A250")
If Application.COUNTA(R) = 0 Then


On Mon, 25 Oct 2004 13:03:07 -0700, "hcova"
wrote:

I need to check if a certain range var is nothing.
Suppose you have the following code

Dim R As Range

If R = Nothing then
End If

When I try to compile this I receive and object error in the If line. Then
how can I test if R has something. Finally IsNull and IsEmpty don´t work too.
Regards


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
Test if a value is in a range of values jfrick Excel Worksheet Functions 9 April 13th 08 09:02 PM
Test within a range? JC Excel Worksheet Functions 3 May 25th 07 03:41 AM
Test if CELL is in RANGE Vaughan Excel Worksheet Functions 12 November 19th 06 02:48 PM
How I set up as logical test if my range has to be >=2 but <5 nsnjlacm Excel Discussion (Misc queries) 2 May 7th 05 08:04 PM
Test if Cell is within Range (name) goepf[_6_] Excel Programming 2 December 3rd 03 03:26 PM


All times are GMT +1. The time now is 11:55 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"