Userform add number of months to date

sd77000

New Member
Joined
Aug 27, 2009
Messages
47
Hello all,

I am creating a userform that I need to add the number of months to a date. I have a combo box where they select between 1-12 (months) and a text box where they enter a date. What I would like is that when the user exits the text box (date), the 'end' date (months entered * the date entered) is displayed in a label.

Thanks in advance,
Steve
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try

Code:
Dim startDate as Date
Dim endDate as Date

startDate = DateValue(txtStartDate.Text)
endDate = DateSerial(Year(startDate), Month(startDate) + Val(ComboBox1.Value), Day(startDate)

txtEndDate = Format(endDate, "dd. mmm yyyy")
 
Upvote 0
Thank you for the assistance, but was unable to get it to work. Am unable to get the date posted in the EndDate box. Here is the code
Code:
Private Sub startdate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim startdate As Date
Dim enddate As Date

startdate = DateValue(txtStartDate.Text)
enddate = DateSerial(Year(startdate), Month(startdate) + Val(ComboBox1.Value), Day(startdate))

txtEndDate = Format(enddate, "dd. mmm yyyy")
End Sub
 
Upvote 0
You need to change the name of the controls to match your names. My code assumes a text box named txtStartDate, but your event code shows that the name is actually startdate. The other controls also need to have their names match.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

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