Add a day to a date

Nomis_Eswod

Board Regular
Joined
Jul 27, 2005
Messages
153
Hi,

I'm using the below code to add the value in TextBox3 to the value in TextBox10, and put it in TextBox12.

TextBox3 is a date and TextBox10 is a number, in this instance a 1.

This works fine, but I want to make a slight change so that it adds exactly 1 day the date in TB10, i.e. if TB10 is Now(), so it shows the date and time, I want TB12 to show tomorrows date, with the same time, so exactly 24 hours on.

Any ideas if this is possible?

Code:
TextBox3.Value = Format(Now, "d-mmmm-yy h:mm")
    TextBox10.Value = 1
    TextBox12.Value = ""
    
newDate = Format(DateValue(TextBox3.Value) + TextBox10.Value, "d-mmmm-yy")


    If Weekday(newDate, vbUseSystemDayOfWeek) = 6 Then
    newDate1 = Format(DateValue(newDate) + 2, "d-mmmm-yy h:mm")
    Else
    If Weekday(newDate, vbUseSystemDayOfWeek) = 7 Then
    newDate1 = Format(DateValue(newDate) + 1, "d-mmmm-yy h:mm")
    Else
    newDate1 = Format(DateValue(newDate), "d-mmmm-yy h:mm")
    End If
    End If
    
If TextBox12.Value = "" Then
TextBox12.Value = Format(DateValue(newDate1), "d-mmmm-yy h:mm")
End If
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hello, Nomis_Eswod,

try this
Code:
TextBox12 = Format(DateValue(TextBox10) + 1 + TimeValue(TextBox10), "d-mmmm-yy h:mm")

(not talking about problems which can occur when user enters date in wrong format)

kind regards,
Erik
 

Nomis_Eswod

Board Regular
Joined
Jul 27, 2005
Messages
153
Thanks for this.

Luckily the user doesn't enter the data, that is done automatically.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,805
Messages
5,833,773
Members
430,232
Latest member
Testsubject

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
Top