David
In [b1]: input the begin date
In [b2]: input the end date
In [a5-a9]: input 0,1,2,3,4 repectively,
in [b5]: copy this formula to the cell and copy down to [b9] and you will get the required calculation.
FORMULA:
=IF(YEAR($B$1)+A5>YEAR($B$2),0,IF(YEAR($B$2)=YEAR($B$1),B2-B1,IF(YEAR($B$2)=YEAR($B$1)+$A5,$B$2-eomonth(TEXT(YEAR($B$2)&"/1/1","YYYY/MM/DD"),-1),IF(AND(YEAR($B$1)+A5>YEAR($B$1),YEAR($B$1)+A5<YEAR($B$2)),eomonth(TEXT(YEAR($B$1)+A5&"/12/1","YYYY/MM/DD"),0)-eomonth(TEXT(YEAR($B$1)+A5&"/1/1","YYYY/MM/DD"),-1),eomonth(TEXT(YEAR($B$1)+A5&"/12/1","YYYY/MM/DD"),0)-$B$1))))
Hope that this would help you, I have tested the formula and it works whenever you type the date.
But the end date MUST BE GREATER THAN the begin date.
David:
I think you have not start the required Add-Ins.
In Excel, choose "Tools", then "Add-Ins", and click on the "VBA Analysis Tools".
Then you could either re-start the Excel and re-open the file, or press "F2" in the formula cell and then press "Enter" again and you will find the formula works well as I could open and have the correct calculation you have entered
It's not so tough... and BTW 2001 results should be 76...
With 10/17/2001 in cell A1 and 9/17/03 in cell A2...
enter {2001;2002;2003;2004;2005} into cells C1:C5.
Finally, enter the formula...
=SUM((YEAR(TREND($A$1:$A$2,{0;1}*($A$2-$A$1)+1,ROW(INDIRECT(1&":"&$A$2-$A$1+1))))=C1)+0)
into cell D1 and copy down to cell D5. That should do it!