Problem working with dates between 29 Jan & 31st Jan using date add

Desmondo

Board Regular
Joined
Feb 27, 2013
Messages
70
I have a userform in which the user completes a text box with a start date. And my userform adds one month, i have only just noticed that this can be an issue in Jan and Feb due to the number of days.

Our payments months are e.g. 12/01/2017 - 11/02/2017
12/02/2017 - 11/02/2017

However our clients can sometimes have start dates of the 30/1/17 & 31/1/17 which gives me a problem as our end dates need to be like this 28/1/17-27/2/17, 30/1/17-27/2/17, 31/1/17 - 28/2/17.

I have not got the foggiest how to approach this.

My code so far that i was using was
Code:
Main.opEndDate.Value = Format((DateAdd("m", 1, opStartDate.Value) - 1), "dd/mm/yyyy")

The user is normally dealing with one month however there are instances where it can be more so date could be changed manually to 30/1/17-29/3/17 etc these dates feed into a calculator which auto loads the dates between until the end date is met.

Can anyone help? I considered hard coding exceptions but i doubt that would be the most efficient as this will happen every year.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,416
Messages
6,119,384
Members
448,889
Latest member
TS_711

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