I'd like to create a macro that will look at what day of the week today is (Monday, Tuesday, Wednesday, etc.) and if the day is a saturday or a sunday then the macro will just stop everything but if it is a weekday (M,T,W,Th,or F) then it will call the next Sub.
Private Sub Workbook_Open()
**If today is Saturday or Sunday Then**
**do nothing**
Else
Call Populate_Workbook()
End If
End Sub
the parts with the ** are the parts that I need help figuring out. If someone ends up figuring this out, can you explain how you came up with the solution? Trying to learn and understand macros more.
Here you go...
Private Sub Workbook_Open()
If Weekday(Date, vbMonday) < 6 Then Populate_Workbook
End Sub
The Weekday() function has an optional 2nd parameter that tells it which day of the week the week starts on. The Weekday() function returns an integer from 1 through 7.
I've instructed it to start the week on MONDAY and so SATURDAY would be 6 and SUNDAY would be 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With