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.
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,048
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
7,988
Try:

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

Watch MrExcel Video

Forum statistics

Threads
1,118,234
Messages
5,571,042
Members
412,358
Latest member
Eng Muhammed
Top