Requirement:
Is there a way of "blocking" weekend dates in a calendar form control ? The user wants users to only be allowed to select dates from Monday to Friday.
Solution:
You can't disable dates, but you can disable, for example a command button, when a weekend date is selected:
Private Sub Calendar1_Click() cmdOK.Enabled = (Weekday(Calendar1.Value) > vbSunday And Weekday(Calendar1.Value) < vbSaturday) End Sub
If you only want a Thursday to be allowed: Change the posted code so the Enabled property is true only if the Weekday of the Calendar.Value is vbThursday.
Obtained from the OzGrid Help Forum.
Solution provided by cytop.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
How to use VBA Code to remove amounts based on days passed |
How to use a macro to auto delete file when passed 15 days |
How to create VBA code for a workbook to work on week days only and specific range of time |
How to count weekdays in a month excluding holidays |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.