PC Review


Reply
Thread Tools Rate Thread

Best way to check if cell is empty??

 
 
Robert Crandal
Guest
Posts: n/a
 
      23rd Dec 2009
I currently use the following code to test if a cell is empty:

If IsEmpty(Sheet1.Range("A1").Value) then
' code here
End If

Are there better or other ways to check if a cell is empty???
Also, does it matter if I put the ".Value" at the end of the
Range("A1") code?

thankx



 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      26th Dec 2009
You don't need the .value, but then you're relying on the default property for
that range (which is .value).

The same way you don't need the .value here:

activesheet.range("A1") = "hi there"

Personally, I think it's much better to include the property--I think it
documents the code better.

And that's the way I'd check to see if the cell were really empty.

If you only cared about what you saw in the cell (a formula could evaluate to
""), you could use:

if sheet1.range("a1").value = "" then

But that really doesn't test for emptiness.

Robert Crandal wrote:
>
> I currently use the following code to test if a cell is empty:
>
> If IsEmpty(Sheet1.Range("A1").Value) then
> ' code here
> End If
>
> Are there better or other ways to check if a cell is empty???
> Also, does it matter if I put the ".Value" at the end of the
> Range("A1") code?
>
> thankx


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to check if cell is empty?? Robert Crandal Microsoft Excel Programming 2 23rd Dec 2009 01:26 PM
check for empty cell =?Utf-8?B?aW5nYWxsYQ==?= Microsoft Excel Programming 1 3rd May 2007 12:09 AM
How do I check for an empty cell in a formula? sasquatchbill Microsoft Excel Misc 4 8th Aug 2006 03:55 PM
Check current cell is empty bobocat Microsoft Excel Discussion 3 6th Jul 2006 11:13 PM
vba - check if cell is empty joao Microsoft Excel Programming 6 18th Nov 2003 03:12 PM


Features
 

Advertising
 

Newsgroups
 


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