How to fix the code for macro?

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

Eric

The following code is not working, does anyone have any suggestions on how to
fix the code for macro?

If or(weekday(Today)=1,weekday(Today)=7,Hour(Now) > 16) Then

Thanks in advance for any suggestions
Eric
 
Hi Eric

Mike meant to say;

If Weekday(Date)=1 OR Weekday(Date)=7 OR Hour(Now) > 16 Then
'if any of the above conditions apply
End If

OR you can try

If Left(Format(Date,"ddd"),1) = "S" OR Hour(Now) > 16 Then
'if any of the above conditions apply
End If


If this post helps click Yes
 
Jacob,

Yes i did mean to say that, I corrected the syntax without checkuing the
code properly. Thanks.

Mike
 
If or(weekday(Today)=1,weekday(Today)=7,Hour(Now) > 16) Then

Hi. Just another option:

'Weekend is 6 or 7
If Weekday(Now, 2) >= 6 Or Hour(Now) > 16 Then

= = = = =
Dana DeLouis
 
Whatever code you use, you may want to replace the numbers that represent the
day of the week with their VBA constants (vbSunday, ..., vbSaturday). VBA's
help shows the list and the values they represent.

It'll make the code a little easier to read in a week or so...
 
I have tried Now for weekday, which is working too.
Thank everyone very much for suggestions
Eric
 
Back
Top