Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default DateSerial vs Date??

Excel 2007 Win 7 64-bit
The range rColJ is a string of cells containing dates, the largest of which
is 6 Dec 09. That string of dates was not changed in the following
troubleshooting procedure.
I want to know if the maximum date in rColJ = 1 Dec 09. My code is:
If Application.Max(rColJ)DateSerial (2009, 12, 1) Then....
The argument is False, even though 6 Dec 09 is in that range.
I changed that line of code and substituted the numerical value of 6 Dec 09
(38686) for the DateSerial expression:
If Application.Max(rColJ)38686 Then....
That argument is True.
What mistake did I make in using the DateSerial VBA function?
Thanks for your time. Otto

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default DateSerial vs Date??


If Application.Max(rColJ)DateSerial (2009, 12, 1) Then....


If the date 1-December-2009 is the maximum date in rColj, the
condtional will be false because it equals DateSerial(2009,12,1) and
your test if for "greater than", not "greater than or equal to".
Change the "" to "=" if you want to include equality.

If Application.Max(rColJ)38686 Then....


The value 38686 is equivalent to 30-Nov-2005, which is certainly less
than 1-Dec-2009.

Think carefully about the logic you need and then write code
accordingly.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Mon, 30 Nov 2009 16:32:35 -0500, "Otto Moehrbach"
wrote:

Excel 2007 Win 7 64-bit
The range rColJ is a string of cells containing dates, the largest of which
is 6 Dec 09. That string of dates was not changed in the following
troubleshooting procedure.
I want to know if the maximum date in rColJ = 1 Dec 09. My code is:
If Application.Max(rColJ)DateSerial (2009, 12, 1) Then....
The argument is False, even though 6 Dec 09 is in that range.
I changed that line of code and substituted the numerical value of 6 Dec 09
(38686) for the DateSerial expression:
If Application.Max(rColJ)38686 Then....
That argument is True.
What mistake did I make in using the DateSerial VBA function?
Thanks for your time. Otto

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default DateSerial vs Date??

Chip
I did test for = in my code, and the maximum date in rColJ was 6 Dec
09, not 1 Dec 09 (see my post). I did have the number, 38686, wrong. It
should have been 40148. Thanks for your time. Otto

"Chip Pearson" wrote in message
...

If Application.Max(rColJ)DateSerial (2009, 12, 1) Then....


If the date 1-December-2009 is the maximum date in rColj, the
condtional will be false because it equals DateSerial(2009,12,1) and
your test if for "greater than", not "greater than or equal to".
Change the "" to "=" if you want to include equality.

If Application.Max(rColJ)38686 Then....


The value 38686 is equivalent to 30-Nov-2005, which is certainly less
than 1-Dec-2009.

Think carefully about the logic you need and then write code
accordingly.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Mon, 30 Nov 2009 16:32:35 -0500, "Otto Moehrbach"
wrote:

Excel 2007 Win 7 64-bit
The range rColJ is a string of cells containing dates, the largest of
which
is 6 Dec 09. That string of dates was not changed in the following
troubleshooting procedure.
I want to know if the maximum date in rColJ = 1 Dec 09. My code is:
If Application.Max(rColJ)DateSerial (2009, 12, 1) Then....
The argument is False, even though 6 Dec 09 is in that range.
I changed that line of code and substituted the numerical value of 6 Dec
09
(38686) for the DateSerial expression:
If Application.Max(rColJ)38686 Then....
That argument is True.
What mistake did I make in using the DateSerial VBA function?
Thanks for your time. 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
DateSerial function inungh Excel Programming 3 December 11th 08 07:59 PM
Recreating the DateSerial()/Date() function Conan Kelly Excel Worksheet Functions 1 March 1st 08 04:43 AM
Recreating the DateSerial()/Date() function Conan Kelly Excel Programming 1 March 1st 08 04:43 AM
using dateserial in vb mwam423 Excel Programming 3 June 14th 07 02:45 AM
DateSerial Troubles rockerx Excel Programming 1 March 14th 07 08:14 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"