How to fix the code for macro?

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
 
J

Jacob Skaria

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
 
M

Mike H

Jacob,

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

Mike
 
D

Dana DeLouis

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
 
D

Dave Peterson

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...
 
E

Eric

I have tried Now for weekday, which is working too.
Thank everyone very much for suggestions
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top