View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_815_] Rick Rothstein \(MVP - VB\)[_815_] is offline
external usenet poster
 
Posts: 1
Default If a date range contains a leap year (date)

Are you working in XL2007? Otherwise, if you are using an earlier version,
won't this...

ROW(INDIRECT(StartDate&":"&EndDate))

part of your formula require the evaluation of a row number greater than
65356 (in other words, past the end of the worksheet's last row) if the
EndDate is past 6/5/2079 (whose numerical value is 65356)?

Try this... put any valid date in A1 and 6/5/2079 in B1... put this formula
in any cell...

=SUMPRODUCT((MONTH(ROW(INDIRECT(A1&":"&B1)))=2)*(D AY(ROW(INDIRECT(A1&":"&B1)))=29))0

The result looks OK. Now add one day to the date in B1 (=6/62079)... I get a
#REF! error when I do that.

Rick


"Ron Rosenfeld" wrote in message
...
On Fri, 4 Jul 2008 17:11:46 -0400, "Rick Rothstein \(MVP - VB\)"
wrote:

it will not work in the
general case if the EndDate is greater than 6/5/2079


I don't understand that limitation.

If I enter

StartDate 1/1/2000
EndDate 12/31/2100

I get TRUE as a result, and the SUMPRODUCT part gives a result of 25,
which I
believe is correct (2000 was a leap year; 2100 will not be).

However, it will not give the correct result if the year 1900 is included
in
the range, since Excel (and Lotus) think 1900 was a leap year.
--ron