How to set TIME condition for if-statement?

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

I would like to process following code if time is between 12:30PM and 2:30PM.
Does anyone have any suggestions on how to code this if-statement in VBA
coding for Excel's macro?
Thanks in advance for any suggestions
Eric

if time is between 12:30PM and 2:30PM then
(
Coding
);
 
There is an error related to if-statement, missing ":",
could you please tell me the format on using if statement
If Time > #12:30:00 PM# And Time < #2:30:00 PM# Then
(
Coding);
End if

Will it be the right format?
Thanks in advance for any suggestions
Eric
 
Your original message said you were looking for a VBA solution, so I'm not
sure why you are showing us pseudo-code snippets that use parentheses as
code-block delimiters... are you really using VBA? The code JLGWhiz posted
works correctly in VBA. If you are using VBA, but still got the error you
are indicating, then did you copy/paste JLGWhiz's code or did you type it
into your program and change some aspect of it? Also, if using VBA, exactly
when did that error message appear to you and exactly what code was
highlighted (copy/paste your code into your reply so we can see it, don't
retype it for us as you may inadvertently correct the error when doing so)?
 
Back
Top