Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Is the cell really blank?

Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for a
blank cell, not for a cell that contains a formula that returns a blank cell
(True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly blank?
Thanks for your help. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is the cell really blank?

isempty has always worked for me when checking a range.

I don't recall seeing that warning, but there are lots of posts to the
newsgroups.



Otto Moehrbach wrote:

Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for a
blank cell, not for a cell that contains a formula that returns a blank cell
(True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly blank?
Thanks for your help. Otto


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Is the cell really blank?

I realize that this check is good only for a blank cell, not for a cell
that contains a formula that returns a blank cell


I have to disagree, Otto. When I run this code:

If ActiveCell.Value = "" Then Beep

when a cell that has this formula in it is selected:

=IF(TRUE,"","")

I get a beep.

--
Jim
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for a
blank cell, not for a cell that contains a formula that returns a blank
cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly
blank? Thanks for your help. Otto



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Is the cell really blank?

It appears that IsEmpty() can distinguish blank from empty:

Sub Macro1()
MsgBox (IsEmpty(Cells(1, 1).Value))
End Sub

will anounce false if A1 contains:

=IF(1=1,"","")


--
Gary's Student


"Otto Moehrbach" wrote:

Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for a
blank cell, not for a cell that contains a formula that returns a blank cell
(True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly blank?
Thanks for your help. Otto



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is the cell really blank?

And after reading Jim Rech's response, I want to clarify mine.

isempty(range("a1")) will return true if there's no formula and no constant in
that cell.

isempty(range("a1")) will return false if there's a formula in that cell--no
matter what it returns.

And to make matters slightly worse, if you convert a formula that evaluated to
"" to a value, then the formula isempty(range("a1")) will return false.

But if range("a1").value = "" won't care if the cell is empty or evaluates to ""
(or used to be a formula that evaluate to "" and was converted to values).
It'll return True.



Dave Peterson wrote:

isempty has always worked for me when checking a range.

I don't recall seeing that warning, but there are lots of posts to the
newsgroups.

Otto Moehrbach wrote:

Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for a
blank cell, not for a cell that contains a formula that returns a blank cell
(True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly blank?
Thanks for your help. Otto


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Is the cell really blank?

Jim
I didn't word my statement correctly. I meant just what you said,
namely that the If ....."" Then is True if the cell is blank, regardless of
why it is blank. Otto
"Jim Rech" wrote in message
...
I realize that this check is good only for a blank cell, not for a cell
that contains a formula that returns a blank cell


I have to disagree, Otto. When I run this code:

If ActiveCell.Value = "" Then Beep

when a cell that has this formula in it is selected:

=IF(TRUE,"","")

I get a beep.

--
Jim
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for
a blank cell, not for a cell that contains a formula that returns a blank
cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly
blank? Thanks for your help. Otto





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Is the cell really blank?

Thanks Dave, Jim, and the Student. That clears it up for me. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only for a
blank cell, not for a cell that contains a formula that returns a blank
cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above (returns
False if it contains the formula). However, I've seen on this newsgroup
that "IsEmpty" should only be used to determine if a variable has been
initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly
blank? Thanks for your help. Otto



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Is the cell really blank?

Hey Otto:

I didn't a little analysis of IsEmpty that you can see here

http://www.dailydoseofexcel.com/arch...r-empty-cells/

I don't think it necessarily adds anything to what was said here, but it
may.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Thanks Dave, Jim, and the Student. That clears it up for me. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only
for a blank cell, not for a cell that contains a formula that
returns a blank cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above
(returns False if it contains the formula). However, I've seen on
this newsgroup that "IsEmpty" should only be used to determine if a
variable has been initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly
blank? Thanks for your help. Otto



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Is the cell really blank?

Dick
That's a good write-up. Thanks for that.
I have one question I want to ask to keep me out of trouble with this in
the future. You say, as have others, that IsEmpty, for the purposes
discussed in this thread, should act on the Value property of the range
object. And that works. But I have always used it (in ignorance???) on the
range object itself, and not on the Value property of the range object. Am
I liable to step in something by doing this? Thanks again. Otto
"Dick Kusleika" wrote in message
...
Hey Otto:

I didn't a little analysis of IsEmpty that you can see here

http://www.dailydoseofexcel.com/arch...r-empty-cells/

I don't think it necessarily adds anything to what was said here, but it
may.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Thanks Dave, Jim, and the Student. That clears it up for me. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only
for a blank cell, not for a cell that contains a formula that
returns a blank cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above
(returns False if it contains the formula). However, I've seen on
this newsgroup that "IsEmpty" should only be used to determine if a
variable has been initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly
blank? Thanks for your help. Otto





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is the cell really blank?

I've been one of the offenders who used
if isempty(somerange) then

But after reading Dick's blog, I'm gonna (try to) change to:
if isempty(somerange.value) then

From an English point, it always made more sense to me to talk about the
container (the cell) than the value. But looking at Dick's screen print, I see
the error of my ways.

But as a saving grace, .value is the default property of a range.



Otto Moehrbach wrote:

Dick
That's a good write-up. Thanks for that.
I have one question I want to ask to keep me out of trouble with this in
the future. You say, as have others, that IsEmpty, for the purposes
discussed in this thread, should act on the Value property of the range
object. And that works. But I have always used it (in ignorance???) on the
range object itself, and not on the Value property of the range object. Am
I liable to step in something by doing this? Thanks again. Otto
"Dick Kusleika" wrote in message
...
Hey Otto:

I didn't a little analysis of IsEmpty that you can see here

http://www.dailydoseofexcel.com/arch...r-empty-cells/

I don't think it necessarily adds anything to what was said here, but it
may.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Thanks Dave, Jim, and the Student. That clears it up for me. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good only
for a blank cell, not for a cell that contains a formula that
returns a blank cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above
(returns False if it contains the formula). However, I've seen on
this newsgroup that "IsEmpty" should only be used to determine if a
variable has been initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is truly
blank? Thanks for your help. Otto




--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Is the cell really blank?

Otto: I agree with everything Dave said. When you leave off the .Value
property, you are still testing the .Value property because it's the default
of the Range object. There are two potential pitfalls to omitting Value:
MS could change the default property or Range; You force the compiler to
look up the default property which is a performance hit.

The performance hit, I'll bet, is so small that you couldn't measure it in a
10,000 line program and the chance that MS will change the default property
is even less. So I think you're safe leaving it off. I tried to get into
the habit of always specifiying the default property a couple of years ago,
which is why I use it.


--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Dick
That's a good write-up. Thanks for that.
I have one question I want to ask to keep me out of trouble with
this in the future. You say, as have others, that IsEmpty, for the
purposes discussed in this thread, should act on the Value property
of the range object. And that works. But I have always used it (in
ignorance???) on the range object itself, and not on the Value
property of the range object. Am I liable to step in something by
doing this? Thanks again. Otto "Dick Kusleika"
wrote in message
...
Hey Otto:

I didn't a little analysis of IsEmpty that you can see here

http://www.dailydoseofexcel.com/arch...r-empty-cells/

I don't think it necessarily adds anything to what was said here,
but it may.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Thanks Dave, Jim, and the Student. That clears it up for me. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good
only for a blank cell, not for a cell that contains a formula that
returns a blank cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above
(returns False if it contains the formula). However, I've seen on
this newsgroup that "IsEmpty" should only be used to determine if a
variable has been initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is
truly blank? Thanks for your help. Otto



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Is the cell really blank?

Dave & Dick
I've resolved to always state the .Value also. Thanks for your help.
Otto
"Dick Kusleika" wrote in message
...
Otto: I agree with everything Dave said. When you leave off the .Value
property, you are still testing the .Value property because it's the
default of the Range object. There are two potential pitfalls to omitting
Value: MS could change the default property or Range; You force the
compiler to look up the default property which is a performance hit.

The performance hit, I'll bet, is so small that you couldn't measure it in
a 10,000 line program and the chance that MS will change the default
property is even less. So I think you're safe leaving it off. I tried to
get into the habit of always specifiying the default property a couple of
years ago, which is why I use it.


--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Dick
That's a good write-up. Thanks for that.
I have one question I want to ask to keep me out of trouble with
this in the future. You say, as have others, that IsEmpty, for the
purposes discussed in this thread, should act on the Value property
of the range object. And that works. But I have always used it (in
ignorance???) on the range object itself, and not on the Value
property of the range object. Am I liable to step in something by
doing this? Thanks again. Otto "Dick Kusleika"
wrote in message
...
Hey Otto:

I didn't a little analysis of IsEmpty that you can see here

http://www.dailydoseofexcel.com/arch...r-empty-cells/

I don't think it necessarily adds anything to what was said here,
but it may.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

Otto Moehrbach wrote:
Thanks Dave, Jim, and the Student. That clears it up for me. Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I've been using
If Range(....)="" Then
to check if a cell is blank. I realize that this check is good
only for a blank cell, not for a cell that contains a formula that
returns a blank cell (True in both cases).
I've also used:
If IsEmpty(Range(....)) Then
and this has been working well including the formula case above
(returns False if it contains the formula). However, I've seen on
this newsgroup that "IsEmpty" should only be used to determine if a
variable has been initialized.
Can anyone clarify the use of IsEmpty to determine if a cell is
truly blank? Thanks for your help. Otto





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
How to return a blank formula cell if the reference is blank? waybomb Excel Worksheet Functions 2 January 22nd 09 05:53 PM
Average Formula to display blank cell if named range is blank Rachael F Excel Worksheet Functions 3 February 22nd 08 05:05 PM
how to get excel to display blank if reference cell blank silent1(not) Excel Worksheet Functions 1 December 2nd 05 02:49 PM
How do I make a blank cell with a date format blank? Pivot Table/Query Excel Worksheet Functions 6 June 14th 05 11:19 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM


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