Calendar Project

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Working on a Planning project for Staff Leave. The first extract shows the current situation, the second is the desired output.

Book4
ABCDEFGHIJKLMNOPQ
1First NameLeave TypeQuantity - DaysStart DateEnd DateJanFebMarAprMayJunJulAugSepOctNovDec
2JackLong Service Leave6522/06/202118/09/2021
3MaryAnnual Leave1812/10/202120/11/2021
4MaryAnnual Leave221/11/202122/11/2021
5PeterLong Service Leave504/01/202108/01/2021
6
7
8First NameLeave TypeQuantity - DaysStart DateEnd DateJanFebMarAprMayJunJulAugSepOctNovDec
9JackLong Service Leave6522/06/202118/09/202116161616
10MaryAnnual Leave2012/10/202120/11/2021911
11PeterLong Service Leave504/01/202108/01/20215
Sheet1


The 3rd column records the number of days which need to be spread out across the next year, in some cases it's half leave but it's the figure contained in Column 3 that is important. The figure placed in the desired extract is simply the entry in Column 3 divided by the number of months spanned by Columns D & E. The first record is 65 divided by 4 and rounded up. Conditional Formatting is then applied to the relevant month(s). Would prefer a Function/Formula approach in the first instance but ultimately I'll take any approach that gets the job done.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
try this, Col R cater for the roundoff errors

Book1
ABCDEFGHIJKLMNOPQR
1First NameLeave TypeQuantity - DaysStart DateEnd DateJanFebMarAprMayJunJulAugSepOctNovDecAdjustment
2JackLong Service Leave6522/06/202118/09/2021     16161616   -1
3MaryAnnual Leave2012/10/202120/11/2021         1010 0
4PeterLong Service Leave504/01/202108/01/20215           0
Sheet1
Cell Formulas
RangeFormula
F2:Q4F2=IF(AND(MONTH(DATEVALUE(F$1&"1"))>=MONTH($D2),MONTH(DATEVALUE(F$1&"1"))<=MONTH($E2)),ROUND($C2/(MONTH($E2)-MONTH($D2)+1),0),"")
R2:R4R2=SUM(F2:Q2)-C2
 
Upvote 0
this version taken into account of the days pro-rata within leave months

Book1
ABCDEFGHIJKLMNOPQ
1First NameLeave TypeQuantity - DaysStart DateEnd DateJanFebMarAprMayJunJulAugSepOctNovDec
2JackLong Service Leave6522/06/202118/09/2021     7222214   
3MaryAnnual Leave2012/10/202120/11/2021         1010 
4PeterLong Service Leave504/01/202108/01/20215           
Sheet1
Cell Formulas
RangeFormula
F2:F4F2=IFERROR(ROUND(IF(MONTH(F$1&" 1")=MONTH($D2),MIN($C2,(DATE(YEAR($E2),MONTH(F$1&" 1"),EOMONTH(MONTH(F$1&" 1"),0)-1)-$D2+1)*$C2/($E2-$D2+1)),IF(MONTH(F$1&" 1")=MONTH($E2),$C2-SUM(E2:$F2),IF(AND(MONTH(F$1&" 1")>MONTH($D2),MONTH(F$1&" 1")<MONTH($E2)),DAY(DATE(YEAR($E2),MONTH(F$1&" 1"),EOMONTH(MONTH(F$1&" 1"),0)-1))*$C2/($E2-$D2+1),""))),0),"")
G2:Q4G2=IFERROR(ROUND(IF(MONTH(G$1&" 1")=MONTH($D2),MIN($C2,(DATE(YEAR($E2),MONTH(G$1&" 1"),EOMONTH(MONTH(G$1&" 1"),0)-1)-$D2+1)*$C2/($E2-$D2+1)),IF(MONTH(G$1&" 1")=MONTH($E2),$C2-SUM($F2:F2),IF(AND(MONTH(G$1&" 1")>MONTH($D2),MONTH(G$1&" 1")<MONTH($E2)),DAY(DATE(YEAR($E2),MONTH(G$1&" 1"),EOMONTH(MONTH(G$1&" 1"),0)-1))*$C2/($E2-$D2+1),""))),0),"")
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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