dateadd not working

smakatura

Board Regular
Joined
May 27, 2011
Messages
141
I want to have a user enter a date, and then have the system tell the user the next day's date.
HTML:
Dim rptdate As Date
 
    rptdate = Application.InputBox("Enter date.", Title:="Date Entry", Type:=1)
 
    MsgBox (DateAdd(d, 1, rptdate))

the msgbox line does not want to work but not sure how to fix it..probably an easy fix.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
dateadd wants a string as the first argument, so the trite answer is, as long as the variable d contains a valid string it should work, but you probably want:
dateadd("d",1,rptdate)
 
Upvote 0
try
Code:
[/FONT]
[FONT=Courier New]Sub test2()
Dim rptdate As Date
rptdate = Application.InputBox("Enter date.", Title:="Date Entry", Type:=1)
MsgBox "The next day will be " & Format(rptdate + 1, "DDDD") & vbNewLine & "Date: " & rptdate + 1, vbInformation, "Answer"
End Sub
 
Upvote 0
using
HTML:
msgbox (rptdate +1)
worked perfectly and did not cause the confusion of the adddate option. if I wanted to do more than just add one day to the date I would exlplore more options.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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