ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Add days to a date (https://www.excelbanter.com/excel-discussion-misc-queries/178115-add-days-date.html)

KK

Add days to a date
 
With three textboxes(1,2 and 3) in a userform1.
If I insert a date in textbox1, how do I get textbox2 to show the date
(textbox1)+90 days and textbox3 to show the date (textbox1)+120 days?
Using vb code?
--
kk

Dave Peterson

Add days to a date
 
Option Explicit
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(Me.TextBox1.Value) Then
Me.TextBox2.Value _
= Format(CDate(Me.TextBox1.Value) + 90, "mmmm dd, yyyy")
Me.TextBox3.Value _
= Format(CDate(Me.TextBox1.Value) + 120, "mmmm dd, yyyy")
Else
Beep
Cancel = True
End If
End Sub


kk wrote:

With three textboxes(1,2 and 3) in a userform1.
If I insert a date in textbox1, how do I get textbox2 to show the date
(textbox1)+90 days and textbox3 to show the date (textbox1)+120 days?
Using vb code?
--
kk


--

Dave Peterson

KK

Add days to a date
 
Excellent, brilliant.
Thank you Dave
--
kk


"Dave Peterson" wrote:

Option Explicit
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(Me.TextBox1.Value) Then
Me.TextBox2.Value _
= Format(CDate(Me.TextBox1.Value) + 90, "mmmm dd, yyyy")
Me.TextBox3.Value _
= Format(CDate(Me.TextBox1.Value) + 120, "mmmm dd, yyyy")
Else
Beep
Cancel = True
End If
End Sub


kk wrote:

With three textboxes(1,2 and 3) in a userform1.
If I insert a date in textbox1, how do I get textbox2 to show the date
(textbox1)+90 days and textbox3 to show the date (textbox1)+120 days?
Using vb code?
--
kk


--

Dave Peterson



All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com