#1   Report Post  
Posted to microsoft.public.excel.misc
CathyZ
 
Posts: n/a
Default date comparison help

Hi,

I'm trying to use the less than operator to compare dates in a worksheet
against the date in a variable. The = sign works ok, but neither the = or
<= does not. Here is the code, any help in using mainly the = operator
would help greatly.

Do While Not IsEmpty(ActiveCell)
If ActiveCell.Value = startDates Then
startRange = ActiveCell.Address
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks
CathyZ
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default date comparison help

A tough one. Is startDates declared as a number, or date variable?
Are the dates in the column Excel-readable dates (a number representing
the elapsed days since 1/1/1900, then formatted as a date)? If the
cells are text instead of numbers and startDates is a string variable,
that would explain why the = sign works but not the = or <=.

  #3   Report Post  
Posted to microsoft.public.excel.misc
CathyZ
 
Posts: n/a
Default date comparison help



"Dave O" wrote:

A tough one. Is startDates declared as a number, or date variable?
Are the dates in the column Excel-readable dates (a number representing
the elapsed days since 1/1/1900, then formatted as a date)? If the
cells are text instead of numbers and startDates is a string variable,
that would explain why the = sign works but not the = or <=.


Hi Dave,
startDates declared as a date
Dim startDates As Date
and the column is formatted as a date, if I enter 1/1/01 it formats it to
01/01/2001,

CathyZ
  #4   Report Post  
Posted to microsoft.public.excel.misc
CathyZ
 
Posts: n/a
Default date comparison help



"Dave O" wrote:

A tough one. Is startDates declared as a number, or date variable?
Are the dates in the column Excel-readable dates (a number representing
the elapsed days since 1/1/1900, then formatted as a date)? If the
cells are text instead of numbers and startDates is a string variable,
that would explain why the = sign works but not the = or <=.


I've sorted it out, what you wrote had me thinking, so I made one change in
my code and I think it works. When I made the worksheet active, I put the
cursor at the top of the column, but the first row had column headings, so I
now made the second row active, instead of the first and it worked. I
thought the program would just see the heading as a string and then go down
to the next row.

But thanks much for jogging my thinking cap.

CathyZ
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default date comparison help

Happy to help, if only indirectly!



  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default date comparison help

Happy to help, if only indirectly!

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
Adding XY days to date in cells satucha Excel Discussion (Misc queries) 1 November 25th 05 08:02 AM
Another Date issue. TimM Excel Worksheet Functions 1 November 17th 05 01:58 AM
Date comparison Jonibenj Excel Discussion (Misc queries) 6 October 23rd 05 08:34 PM
Date Math Problem Dkline Excel Worksheet Functions 4 March 4th 05 04:11 PM
Need help troubleshooting an array formula XLXP on Win2K KR Excel Worksheet Functions 1 December 13th 04 07:41 PM


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