Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Date variables and empty cells?

I'm working on a program that works with a lot of dates. I found that if I
set a date variable equal to a cell that might contain a date or might be
empty, if the cell is empty, it returns "12:00:00 AM" which I assume to be
midnight, Jan. 1, 1900, which is more difficult to test for than a blank
cell. So it seems to me that it would be better to use a variant type
variable here instead of a date variable since I have to test for blank
cells. The variant returns "empty" for blank cells, and dates for cells
with dates in them. Am I on the right track, or headed off on a spur?

If I do use the variants, how do I test for "Empty"? Is it just "If rRange
= "empty", or do I need to use something else? Will testing for "" work for
this? Basically, I have several tests where if the cell is blank, do
something, if it has a date in it, do something else.

Any thoughts any of you experts has on working with dates and blank cells
will be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date variables and empty cells?

The problem is not the empty cell, that is returning the empty string; the
problem is you are putting it into a variable declared as being of type
Date. However, this is not hard to test for at all...

If YourDateVariable = 0 Then 'Assume there is no date in the cell

or, you could test the cell directly...

If Range("A1").Value = "" Then 'There is nothing in the cell

Rick


"salgud" wrote in message
. ..
I'm working on a program that works with a lot of dates. I found that if I
set a date variable equal to a cell that might contain a date or might be
empty, if the cell is empty, it returns "12:00:00 AM" which I assume to be
midnight, Jan. 1, 1900, which is more difficult to test for than a blank
cell. So it seems to me that it would be better to use a variant type
variable here instead of a date variable since I have to test for blank
cells. The variant returns "empty" for blank cells, and dates for cells
with dates in them. Am I on the right track, or headed off on a spur?

If I do use the variants, how do I test for "Empty"? Is it just "If rRange
= "empty", or do I need to use something else? Will testing for "" work
for
this? Basically, I have several tests where if the cell is blank, do
something, if it has a date in it, do something else.

Any thoughts any of you experts has on working with dates and blank cells
will be greatly appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Date variables and empty cells?

test for 0

Cliff Edwards

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
Excel: Format empty date cells kogrady Excel Discussion (Misc queries) 3 July 8th 09 10:03 PM
Delete Rows with Empty Cells with empty column 1 Scott Excel Programming 5 October 2nd 06 11:57 PM
Excel - Autom. Filter "Empty / Non Empty cells" should come first Rom Excel Discussion (Misc queries) 0 August 10th 05 04:32 PM
macro to colour empty cells (cells not recognized as empty) Gerben Excel Programming 5 June 30th 05 03:29 PM
Can blank cells created using empty Double-Quotes not be empty?? JohnI in Brisbane Excel Programming 6 September 7th 03 11:22 PM


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