Calculate next quarter end date in VBA

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
72,136
Office Version
  1. 365
Platform
  1. Windows
In cell B5 of my spreadsheet, I have a month end date. It will always be the last day of a month (i.e. 1/31/03, 2/28/03, etc.).

In VBA, I need to calculate the following quarter end date based on this date. Essentially, whatever the date is in cell B5, I need to calculate the month end date 3 months into the future.

Here are some examples of dates in B5 and what they should convert to:
1/31/03 -> 4/30/03
9/30/03 -> 12/31/03
11/30/03 -> 2/29/04
etc.

I am working on some code, but it is rather messy, and I would be interested in seeing if others can come up with a simpler, cleaner, solution.

TIA.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
As a regular function try =DATE(YEAR(B5),MONTH(B5)+4,0)

so with VBA use Dateserial
 
Upvote 0
Thanks Dave. They key I needed was DATESERIAL (I couldn't find the VBA equivalent of the DATE function). It is easy enough to do in Excel, it was the VBA part that was giving me problems.

DateSerial(Year(Range("B5")), Month(Range("B5")) + 4, 0)
works great!
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,424
Members
448,896
Latest member
MadMarty

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