XL Problem - Distribute No of Days in Months - Subtract 2 dates

Rahim.Zulfiqar.Ali

New Member
Joined
Sep 28, 2011
Messages
4
XL Problem - Distribute No of Days in respective months Months - Subtract 2 dates and follow current month

Unable to pos attachments, Please provide email address so that I can send you the file.

PROBLEM:
There are 2 columns namely START_DATE and END_DATE, If we subtract both dates we will have Total NO of Days.
For the 1st Customer its start date is 10-MAY-2012 and Ending date is 04-JULY-2012 which has total of 55 days in 3 months
Now for these 3 months I have to distribute the days MONTH WISE in the months cells given above highlighted in GREEN
For may it gives me 21 days for JUNE it gives me 30 and for JULY remaining 04 days and in rest of the months if fills FALSE

BUT the scenerio for next customer is change he has now more months days to distribute
So I require a formula / function or macro to solve this issue

You can add the columns or rows for getting the solution
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th><th>M</th><th>N</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">Start</td><td style=";">End</td><td style="text-align: right;;">January</td><td style="text-align: right;;">February</td><td style="text-align: right;;">March</td><td style="text-align: right;;">April</td><td style="text-align: right;;">May</td><td style="text-align: right;;">June</td><td style="text-align: right;;">July</td><td style="text-align: right;;">August</td><td style="text-align: right;;">September</td><td style="text-align: right;;">October</td><td style="text-align: right;;">November</td><td style="text-align: right;;">December</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Jul-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">31</td><td style="text-align: right;;">24</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Aug-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">25</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Sep-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">25</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Oct-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">31</td><td style="text-align: right;;">24</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;">10-Jun-11</td><td style="text-align: right;;">04-Nov-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">25</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;">10-Jul-11</td><td style="text-align: right;;">04-Dec-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">31</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">24</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;">10-Aug-11</td><td style="text-align: right;;">04-Jan-12</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">25</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">A$2</font>)>MONTH(<font color="Red">C$1</font>),0,IF(<font color="Red">$B2-$A2 >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">C$1</font>),MONTH(<font color="Teal">C$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">C$1</font>),MONTH(<font color="Teal">C$1</font>)+1,0</font>)</font>)-DAY(<font color="Green">A2</font>),$B2-$A2</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">D2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">D$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:C2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">D$1</font>),MONTH(<font color="Teal">D$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">D$1</font>),MONTH(<font color="Teal">D$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:C2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">E2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">E$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:D2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">E$1</font>),MONTH(<font color="Teal">E$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">E$1</font>),MONTH(<font color="Teal">E$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:D2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">F2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">F$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:E2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">F$1</font>),MONTH(<font color="Teal">F$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">F$1</font>),MONTH(<font color="Teal">F$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:E2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">G2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">G$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:F2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">G$1</font>),MONTH(<font color="Teal">G$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">G$1</font>),MONTH(<font color="Teal">G$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:F2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">H2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">H$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:G2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">H$1</font>),MONTH(<font color="Teal">H$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">H$1</font>),MONTH(<font color="Teal">H$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:G2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">I2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">I$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:H2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">I$1</font>),MONTH(<font color="Teal">I$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">I$1</font>),MONTH(<font color="Teal">I$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:H2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">J2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">J$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:I2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">J$1</font>),MONTH(<font color="Teal">J$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">J$1</font>),MONTH(<font color="Teal">J$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:I2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">K2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">K$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:J2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">K$1</font>),MONTH(<font color="Teal">K$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">K$1</font>),MONTH(<font color="Teal">K$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:J2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">L2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">L$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:K2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">L$1</font>),MONTH(<font color="Teal">L$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">L$1</font>),MONTH(<font color="Teal">L$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:K2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">M2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">M$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:L2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">M$1</font>),MONTH(<font color="Teal">M$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">M$1</font>),MONTH(<font color="Teal">M$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:L2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">N2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">N$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:M2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">N$1</font>),MONTH(<font color="Teal">N$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">N$1</font>),MONTH(<font color="Teal">N$1</font>)+1,0</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:M2</font>)</font>)</font>)</td></tr></tbody></table></td></tr></table><br />

Header Row from C1 to N1 contains dates (C1 = 01/01/2011, D1 = 01/02/2011) formatted using a custom date format mmmm

almost there. One more post and I think I'll have it :)
 
Upvote 0
Right I think I got it.
I just hope that this is what you asked for.

<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th><th>M</th><th>N</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">Start</td><td style=";">End</td><td style="text-align: right;;">January</td><td style="text-align: right;;">February</td><td style="text-align: right;;">March</td><td style="text-align: right;;">April</td><td style="text-align: right;;">May</td><td style="text-align: right;;">June</td><td style="text-align: right;;">July</td><td style="text-align: right;;">August</td><td style="text-align: right;;">September</td><td style="text-align: right;;">October</td><td style="text-align: right;;">November</td><td style="text-align: right;;">December</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Jul-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">21</td><td style="text-align: right;;">30</td><td style="text-align: right;;">4</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Aug-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">21</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">4</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Sep-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">21</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">31</td><td style="text-align: right;;">4</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">10-May-11</td><td style="text-align: right;;">04-Oct-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">21</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">4</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;">10-Jun-11</td><td style="text-align: right;;">04-Nov-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">20</td><td style="text-align: right;;">31</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">4</td><td style="text-align: right;;">0</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;">10-Jul-11</td><td style="text-align: right;;">04-Dec-11</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">21</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;">10-Aug-11</td><td style="text-align: right;;">04-Jan-12</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">21</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td><td style="text-align: right;;">30</td><td style="text-align: right;;">31</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">A$2</font>)>MONTH(<font color="Red">C$1</font>),0,IF(<font color="Red">$B2-$A2 >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">C$1</font>),MONTH(<font color="Teal">C$1</font>)+1,0</font>)</font>),DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">C$1</font>),MONTH(<font color="Teal">C$1</font>)+1,0</font>)</font>)-DAY(<font color="Green">A2</font>),$B2-$A2</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">D2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">D$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:C2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">D$1</font>),MONTH(<font color="Teal">D$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">D$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">D$1</font>),MONTH(<font color="#FF00FF">D$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">D$1</font>),MONTH(<font color="#FF00FF">D$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:C2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">E2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">E$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:D2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">E$1</font>),MONTH(<font color="Teal">E$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">E$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">E$1</font>),MONTH(<font color="#FF00FF">E$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">E$1</font>),MONTH(<font color="#FF00FF">E$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:D2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">F2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">F$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:E2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">F$1</font>),MONTH(<font color="Teal">F$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">F$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">F$1</font>),MONTH(<font color="#FF00FF">F$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">F$1</font>),MONTH(<font color="#FF00FF">F$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:E2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">G2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">G$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:F2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">G$1</font>),MONTH(<font color="Teal">G$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">G$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">G$1</font>),MONTH(<font color="#FF00FF">G$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">G$1</font>),MONTH(<font color="#FF00FF">G$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:F2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">H2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">H$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:G2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">H$1</font>),MONTH(<font color="Teal">H$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">H$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">H$1</font>),MONTH(<font color="#FF00FF">H$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">H$1</font>),MONTH(<font color="#FF00FF">H$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:G2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">I2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">I$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:H2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">I$1</font>),MONTH(<font color="Teal">I$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">I$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">I$1</font>),MONTH(<font color="#FF00FF">I$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">I$1</font>),MONTH(<font color="#FF00FF">I$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:H2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">J2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">J$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:I2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">J$1</font>),MONTH(<font color="Teal">J$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">J$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">J$1</font>),MONTH(<font color="#FF00FF">J$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">J$1</font>),MONTH(<font color="#FF00FF">J$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:I2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">K2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">K$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:J2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">K$1</font>),MONTH(<font color="Teal">K$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">K$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">K$1</font>),MONTH(<font color="#FF00FF">K$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">K$1</font>),MONTH(<font color="#FF00FF">K$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:J2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">L2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">L$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:K2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">L$1</font>),MONTH(<font color="Teal">L$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">L$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">L$1</font>),MONTH(<font color="#FF00FF">L$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">L$1</font>),MONTH(<font color="#FF00FF">L$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:K2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">M2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">M$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:L2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">M$1</font>),MONTH(<font color="Teal">M$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">M$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">M$1</font>),MONTH(<font color="#FF00FF">M$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">M$1</font>),MONTH(<font color="#FF00FF">M$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:L2</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">N2</th><td style="text-align:left">=IF(<font color="Blue">MONTH(<font color="Red">$A2</font>)>MONTH(<font color="Red">N$1</font>),0,IF(<font color="Red">(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:M2</font>) >DAY(<font color="Green">DATE(<font color="Purple">YEAR(<font color="Teal">N$1</font>),MONTH(<font color="Teal">N$1</font>)+1,0</font>)</font>),IF(<font color="Green">MONTH(<font color="Purple">$A2</font>)=MONTH(<font color="Purple">N$1</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">N$1</font>),MONTH(<font color="#FF00FF">N$1</font>)+1,0</font>)</font>)-DAY(<font color="Purple">$A2</font>),DAY(<font color="Purple">DATE(<font color="Teal">YEAR(<font color="#FF00FF">N$1</font>),MONTH(<font color="#FF00FF">N$1</font>)+1,0</font>)</font>)</font>),(<font color="Green">$B2-$A2</font>)-SUM(<font color="Green">$C2:M2</font>)</font>)</font>)</td></tr></tbody></table></td></tr></table><br />
 
Upvote 0
You could get that result with this formula in C2 copied across and down

=MAX(0,MIN(EOMONTH(C$1,0),$B2)-MAX(C$1,$A2+1)+1)

Note that if start on 10th May through to beyond the end of May then the logical consequence of that is that if you start on 31st May the number of days in May is zero, is that right?
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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