I have a series of Application.OnTime codes that need ran on specific days throughout the week (M-F). I don't need these codes to run on Saturday/Sunday. How do I code in to only run M-F? The Application.OnKey codes need to run every day. Thank you
'Set keyboard shortcuts
Application.OnKey "^+{UP}", "Sheet4.SpinButton1_SpinDown"
Application.OnKey "^+{DOWN}", "Sheet4.SpinButton1_SpinUp"
If Weekday(Now()) > 2 And Weekday(Now()) < 7 Then Call Workbook_Open
Application.OnTime TimeValue("17:15:00"), "Saveit"
Application.OnTime TimeValue("17:17:00"), "MASTER"
Application.OnTime TimeValue("17:33:00"), "MASTER"
Application.OnTime TimeValue("17:59:00"), "MASTER"
Application.OnTime TimeValue("18:21:00"), "MASTER"
Application.OnTime TimeValue("18:45:00"), "MASTER"
Application.OnTime TimeValue("19:03:00"), "MASTER"
Application.OnTime TimeValue("19:23:00"), "MASTER"
Application.OnTime TimeValue("19:41:00"), "MASTER"
End Sub```
If your code is working OK without the
IF
, then what I suggested in the comments should work.Is this how you modified your code in response to my comments?
I used
Date
instead ofNow
but they should give the same results. Also the()
after theNow
are not needed in VBAI also used
>=2
since you indicated M-F, i.e: you wanted to include Monday