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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
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
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,053
Office Version
  1. 365
Try:

Code:
If TimeValue(Now) > TimeValue("3:50 PM") Then 
DepositDate = Date + 1 
Else 
DepositDate = Date
End If
 
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,164,552
Messages
5,838,063
Members
430,527
Latest member
MyFace2

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