Adding a value to a date

Nomis_Eswod

Board Regular
Joined
Jul 27, 2005
Messages
153
Hi,

i'm trying to use the below code to automatically add a date to 1 textbox and the value 1 to another. Then using the third I want to add the 2 values, so that the third textbox shows the date from the first text plus 1 day.

For example, TextBox3 shows todays date, TextBox 9 shows one, so I want TextBox 11 to show tomorrows date.

However, it is currently adding a 1 onto the end of the date. Any ideas how to get around this?

Code:
Private Sub TextBox11_Enter()
TextBox11.Value = TextBox3.Value + TextBox9.Value
End Sub

Private Sub TextBox3_Enter()
TextBox3.Value = Format(Date, "d-mmmm-yy")
End Sub

Private Sub TextBox9_Enter()

TextBox9.Value = 1

End Sub

Many thanks!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You have to convert the date string to a date, otherwise the + will behave like &:

Code:
Private Sub TextBox11_Enter()
   TextBox11.Value = Format(DateValue(TextBox3.Text) + TextBox9.Value, "d-mmmm-yy")
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,531
Messages
6,185,482
Members
453,297
Latest member
alvintranvcu123

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