Leap Year Issue

FuNeS13

Board Regular
Joined
Oct 25, 2016
Messages
160
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
This is one of the most stressful reports I have ever helped with and I am out of ideas... I have the following Formula:

=($C$3/(($E$3+365)-$E$3))*DAY(EOMONTH($E$3,$T11))

Where:

C3 = 80,000
E3 = 2/1/2024
T11 = 0 (it goes down row by row and adds 1 each row).

Basically what it does it divides the 80,000 by the number of days in a year (365) and then multiplies the result for the number of days in the first month, in this case february (2024).

As you can imagine the formula works great when I put an early non leap year date (for example 2/1/2021) and it some cases other months as well... If my date is 3/1/2023 the formula add an aditional day to the total sum which is located in P23 and it should match the amount in C3...

I'm out of ideas and I have no idea how to make this work for leap year dates as well...

has anymore encountered anything like this?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Your problem is that static 365 in the equation. The 365 has to be 366 when the next Feb in the list of twelve months (i.e., P11 to P22, I surmise) is one with 29 days. I concocted this formula to do that. It looks like the dog's breakfast, but it works.

Put this in P11 instead.

=$C$3/IF(DAY(EOMONTH(IF(MONTH($E$3)>2,DATE(YEAR($E$3)+1,2,1),DATE(YEAR($E$3),2,1)),0))=29,366,365)*DAY(EOMONTH($E$3,$T11))
 
Upvote 0
Maybe this modification of your formula will produce the results you want...

=($C$3/(($E$3+365+(MONTH(DATE(YEAR($E$3),2,29))=2))-$E$3))*DAY(EOMONTH($E$3,$T11))

What I added in red will add 1 to the 365 if the month number for February 29th is 2 (it will be 3 otherwise) which would be the case for a leap year. The EOMONTH function is smart enough to handle leap years so nothing needs to be done with it.
 
Upvote 0
I am not clear on your complete challenge. The allocation shown below may help.
The months are dates like Feb 1 2024 formatted to show months-years.

T202003a.xlsm
ABCDEFGH
1Allocate to months
2StartEndAmountTotalFeb-24Mar-24Apr-24May-24
301-Feb-2431-Dec-2480,000.003356,925.377,402.997,164.187,402.99
415-Feb-2431-May-241,000.00107140.19289.72280.37289.72
1dd
Cell Formulas
RangeFormula
D3:D4D3=B3-A3+1
E3:H4E3=MAX(0, MIN(EOMONTH(E$2, 0), $B3) + 1 - MAX(E$2, $A3))*$C3/$D3
 
Upvote 0
It seems to work for me.

MrExcel posts18.xlsx
CDEFGHIOPT
2next FebDays in Next Febdays to use
3800003/1/20232/1/202429366
4
5
6
7
8
9
10218.5792
11316775.9560
12306557.3771
13316775.9562
14306557.3773
15316775.9564
16316775.9565
17306557.3776
18316775.9567
19306557.3778
20316775.9569
21316775.95610
22296338.79811
2380000
Sheet8
Cell Formulas
RangeFormula
F3F3=IF(MONTH(E3)>2,DATE(YEAR(E3)+1,2,1),DATE(YEAR(E3),2,1))
G3G3=DAY(EOMONTH(IF(MONTH(E3)>2,DATE(YEAR(E3)+1,2,1),DATE(YEAR(E3),2,1)),0))
H3H3=IF(DAY(EOMONTH(IF(MONTH(E3)>2,DATE(YEAR(E3)+1,2,1),DATE(YEAR(E3),2,1)),0))=29,366,365)
O10O10=$C$3/IF(DAY(EOMONTH(IF(MONTH($E$3)>2,DATE(YEAR($E$3)+1,2,1),DATE(YEAR($E$3),2,1)),0))=29,366,365)
O11:O22O11=DAY(EOMONTH($E$3,$T11))
T12:T22T12=T11+1
P11:P22P11=$C$3/IF(DAY(EOMONTH(IF(MONTH($E$3)>2,DATE(YEAR($E$3)+1,2,1),DATE(YEAR($E$3),2,1)),0))=29,366,365)*DAY(EOMONTH($E$3,$T11))
P23P23=SUM(P11:P22)
 
Upvote 0
It seems to work for me.

MrExcel posts18.xlsx
CDEFGHIOPT
2next FebDays in Next Febdays to use
3800003/1/20232/1/202429366
4
5
6
7
8
9
10218.5792
11316775.9560
12306557.3771
13316775.9562
14306557.3773
15316775.9564
16316775.9565
17306557.3776
18316775.9567
19306557.3778
20316775.9569
21316775.95610
22296338.79811
2380000
Sheet8
Cell Formulas
RangeFormula
F3F3=IF(MONTH(E3)>2,DATE(YEAR(E3)+1,2,1),DATE(YEAR(E3),2,1))
G3G3=DAY(EOMONTH(IF(MONTH(E3)>2,DATE(YEAR(E3)+1,2,1),DATE(YEAR(E3),2,1)),0))
H3H3=IF(DAY(EOMONTH(IF(MONTH(E3)>2,DATE(YEAR(E3)+1,2,1),DATE(YEAR(E3),2,1)),0))=29,366,365)
O10O10=$C$3/IF(DAY(EOMONTH(IF(MONTH($E$3)>2,DATE(YEAR($E$3)+1,2,1),DATE(YEAR($E$3),2,1)),0))=29,366,365)
O11:O22O11=DAY(EOMONTH($E$3,$T11))
T12:T22T12=T11+1
P11:P22P11=$C$3/IF(DAY(EOMONTH(IF(MONTH($E$3)>2,DATE(YEAR($E$3)+1,2,1),DATE(YEAR($E$3),2,1)),0))=29,366,365)*DAY(EOMONTH($E$3,$T11))
P23P23=SUM(P11:P22)
thank you!!!
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top