Test if the range is empty

D

dan

I need a VBA code to ensure the range to be filled, is empty to begin.
I will select the range, test if the range is empty, then proceed
accordingly.
Thanks
 
J

JMay

Jim - I opened a new workbook - made no entries into sheet1 (the
activesheet)..

From the immediate Window I entered:
set rng = Activesheet.Range("G1:G5")
? rng.address
$G$1:$G$5
? isempty(rng)
FALSE << WHY???

TIA,
Jim
 
J

Jim Cone

I would say you are asking it to do something beyond its
design specs. I can't give you the technical explanation,
but the help file says IsEmpty only works on Variant variables.
The fact that it works on single cells is just a nice bonus.
For what it's worth, I usually use Len to check a single cell.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"JMay" <[email protected]>
wrote in message
Jim - I opened a new workbook - made no entries into sheet1 (the
activesheet)..

From the immediate Window I entered:
set rng = Activesheet.Range("G1:G5")
? rng.address
$G$1:$G$5
? isempty(rng)
FALSE << WHY???
TIA,
Jim
 
J

JMay

Thanks for your help.
Jim also

I would say you are asking it to do something beyond its
design specs. I can't give you the technical explanation,
but the help file says IsEmpty only works on Variant variables.
The fact that it works on single cells is just a nice bonus.
For what it's worth, I usually use Len to check a single cell.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"JMay" <[email protected]>
wrote in message
Jim - I opened a new workbook - made no entries into sheet1 (the
activesheet)..

From the immediate Window I entered:
set rng = Activesheet.Range("G1:G5")
? rng.address
$G$1:$G$5
? isempty(rng)
FALSE << WHY???
TIA,
Jim
 
D

Dave Peterson

isempty(range("a1").value) will work on a single cell.

That's why Jim used application.counta() for multiple cells.
 
Top