Calculate Each quarter 90 days but year end should be 365/366 days for each year

aaleem

Board Regular
Joined
Sep 26, 2014
Messages
56
Office Version
  1. 2016
I have multiple leases, where I have a start date and expiry dates, I would like to get the quarterly dates between the start date and expiry date for each year with the condition that each quarter (Q1, Q2, Q3) should be 90 days but Q4 should be 365 or 366 days from the start date
Quarterly Payment dates-90 days conditon.PNG.
I'm attaching a screenshot for two leases, is there any excel formula or VBA to get this desired result.

thanks
aleem
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Can you post your data using the boards XL2BB addin please so that we don't have to retype it to test.
To install XL2BB click the XL2BB icon in the Reply window which is a link to the download and instructions.
 
Upvote 0
Rental Cheque Dates Calculation.xlsm
ABCDEFGHIJ
1Start Date02-10-17Start Date14-05-19
2Expiry Date01-10-22Expiry Date13-05-24
3Quarter
4Cheques DatesCheques DatesBasis
502-10-17Ist Payment on start Date14-05-19Ist Payment on start Date
631-12-17Qtr190 Days12-08-19Qtr190 Days
731-03-18Qtr290 Days10-11-19Qtr290 Days
829-06-18Qtr390 Days08-02-20Qtr390 Days
902-10-18Qtr4365 days from the start date14-05-20Qtr4366 days from the start date due to leap year
1031-12-18Qtr190 Days12-08-20Qtr190 Days
1131-03-19Qtr290 Days10-11-20Qtr290 Days
1229-06-19Qtr390 Days08-02-21Qtr390 Days
1302-10-19Qtr4365 days from the start date14-05-21Qtr4365 days from the start date
1431-12-19Qtr190 Days12-08-21Qtr190 Days
1530-03-20Qtr290 Days10-11-21Qtr290 Days
1628-06-20Qtr390 Days08-02-22Qtr390 Days
1702-10-20Qtr4366 days from the start date due to leap year14-05-22Qtr4365 days from the start date
1831-12-20Qtr190 Days12-08-22Qtr190 Days
1931-03-21Qtr290 Days10-11-22Qtr290 Days
2029-06-21Qtr390 Days08-02-23Qtr390 Days
2102-10-21Qtr4365 days from the start date14-05-23Qtr4365 days from the start date
2231-12-21Qtr190 Days12-08-23Qtr190 Days
2331-03-22Qtr290 Days10-11-23Qtr290 Days
2429-06-22Qtr390 Days08-02-24Qtr390 Days
25Qtr4365 days from the start dateQtr4365 days from the start date
Sheet1
Cell Formulas
RangeFormula
H22:H24,H18:H20,H14:H16,H10:H12,H6:H8,C22:C24,C18:C20,C14:C16,C10:C12,C6:C8C6=C5+90
C9,H21,H17,H13,C21,C13C9=C5+365
C17,H9C17=C13+366
 
Upvote 0
Thank you Mark for visiting my post. I tried to get the desired result via VBA, the quarter dates are coming correctly however when it comes to each year-end the dates are not correct. Please see the VBA code. Any suggestions will be much appreciated.
VBA Code:
Sub qtrcalc()

Dim StartDate As Date
Dim EndDate As Date
Dim z As Integer
Dim ldate As Date
Dim x As Integer

StartDate = Range("c1")
EndDate = Range("c2")


z = DateDiff("q", StartDate, EndDate) 

ldate = DateAdd("d", 90, StartDate)

            Range("c27").Value = ldate

Range("c27").Value = StartDate

For x = 28 To 28 + z - 2
        
    Cells(x, 3).Value = DateAdd("d", 90, StartDate)
    StartDate = Cells(x, 3)

Next x

End Sub
 
Upvote 0
i think i crack this, still i request the Gurus to see if any better approach can be made, the results are perfect.
VBA Code:
Sub qtrcalc()

Dim StartDate As Date
Dim EndDate As Date
Dim z As Integer
Dim ldate As Date
Dim x As Integer
Dim k As Integer
Dim Ydate As Date

StartDate = Range("c1")
EndDate = Range("c2")


z = DateDiff("q", StartDate, EndDate) '+ 1 ' for begining of the month date

ldate = DateAdd("d", 90, StartDate) 'for the end date based on freq

            Range("c27").Value = ldate

Range("c27").Value = StartDate


For x = 28 To 28 + z - 2
    
    Cells(x, 3).Value = DateAdd("d", 90, StartDate)
    
        Ydate = Range("c1").Value
        For k = 31 To 31 + z - 5 Step 4
        Cells(k, 3).Value = DateAdd("yyyy", 1, Ydate)
        Ydate = Cells(k, 3)
        Next k
        
    StartDate = Cells(x, 3)
    
      
Next x


End Sub
 
Upvote 0
Upvote 0
The trick is to use the Date function to calculate the year end. Simply add 1 year to the previous year end and it will take care of the leap years.

HTH
 
Upvote 0
Just a bit of an amendment to the formula by pjmorris to match your rows and to allow for dragging down from C6
Book1
BCD
1Start Date02-Oct-17
2Expiry Date01-Oct-22
3Quarter
4Cheques Dates
502-Oct-17
631-Dec-17Qtr1
731-Mar-18Qtr2
829-Jun-18Qtr3
902-Oct-18Qtr4
1031-Dec-18Qtr1
1131-Mar-19Qtr2
1229-Jun-19Qtr3
1302-Oct-19Qtr4
1431-Dec-19Qtr1
1530-Mar-20Qtr2
1628-Jun-20Qtr3
1702-Oct-20Qtr4
1831-Dec-20Qtr1
1931-Mar-21Qtr2
2029-Jun-21Qtr3
2102-Oct-21Qtr4
2231-Dec-21Qtr1
2331-Mar-22Qtr2
2429-Jun-22Qtr3
Sheet3
Cell Formulas
RangeFormula
C5C5=C1
C6:C24C6=IF(MOD(ROW()-1,4)=0,DATE(YEAR(INDEX(C:C,ROW()-4))+1,10,2),C5+90)
 
Upvote 0
Thank you so much Mark, brilliant piece of the formula.
much appreciate your time.

regards
aleem
 
Upvote 0
You're welcome.
Up to you to decide whether a formula or VBA (BTW I haven't tested your VBA) is easiest for your purposes.

Edit: because of the 2nd half of your image then you will need to reference the Start date in the formula rather than hard code the day/month as I did in my formula (the formula pjmorris posted already does this, my fault for being lazy in mine) i.e.

Book1
BCDE
1Start Date14-May-19
2Expiry Date13-May-24
3Quarter
4Cheques Dates
514-May-19Ist Payment on start Date
612-Aug-19Qtr190 Days
710-Nov-19Qtr290 Days
808-Feb-20Qtr390 Days
914-May-20Qtr4365 days from the start date
1012-Aug-20Qtr190 Days
1110-Nov-20Qtr290 Days
1208-Feb-21Qtr390 Days
1314-May-21Qtr4365 days from the start date
1412-Aug-21Qtr190 Days
1510-Nov-21Qtr290 Days
1608-Feb-22Qtr390 Days
1714-May-22Qtr4366 days from the start date due to leap year
1812-Aug-22Qtr190 Days
1910-Nov-22Qtr290 Days
2008-Feb-23Qtr390 Days
2114-May-23Qtr4365 days from the start date
2212-Aug-23Qtr190 Days
2310-Nov-23Qtr290 Days
2408-Feb-24Qtr390 Days
2514-May-24Qtr4Qtr4
Sheet3
Cell Formulas
RangeFormula
C5C5=C1
C6:C25C6=IF(MOD(ROW()-1,4)=0,DATE(YEAR(INDEX(C:C,ROW()-4))+1,MONTH($C$1),DAY($C$1)),C5+90)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,825
Members
449,096
Latest member
Erald

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