Enter today's or tomorrow's date in cell based on time now

Berko

Board Regular
Joined
Oct 13, 2005
Messages
64
I have a macro that produces a report that has to be turned in with a date on it. Sometimes, the report will be prepared the night before to be turned in the following morning. Other times, the morning person will prepare the report. I need a routine in my macro that does something like
Code:
If Time(Now) > 3:50 PM Then
DepositDate = DateSerial(Year(Now), Month(Now), Day(Now) + 1)
Else
DepositDate = Date(Now)
End If
Obviously the above code is not correct, but I thought I would give an example of what I'm trying to do.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
This seems to work.
Code:
If (Now - Int(Now)) > TimeValue("3:50 PM") Then
    DepositDate = DateSerial(Year(Now), Month(Now), Day(Now) + 1)
Else
    DepositDate = Date
End If
 
Upvote 0
Try:

Code:
If TimeValue(Now) > TimeValue("3:50 PM") Then 
DepositDate = Date + 1 
Else 
DepositDate = Date
End If
 
Upvote 0

Forum statistics

Threads
1,215,869
Messages
6,127,415
Members
449,382
Latest member
DonnaRisso

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