Code to Check Time

Novice1

Registered User.
Local time
Today, 00:27
Joined
Mar 9, 2004
Messages
385
I need help writing the correct VBA code ... I want to create an If/Then statement that checks the time. If the time is between 09:00 and 3:00 pm then (pop up msgbox)...

I'm not writing the time code correctly ... any help will be appreciated.

If Now() = Between >= [09:00:00] And <= [15:00:00] Then
 
It would be:

Code:
If Time Between #09:00:00# And #15:00:00# Then

You use the TIME function instead of NOW and you don't use Time = Between - just Time Between.
 
If Hour(Now()) >= 9 And Hour(Now()) <= 15 Then

HTH

leddy

see Bob's post above ;)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom