ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Day test question (https://www.excelbanter.com/excel-programming/419995-day-test-question.html)

Patrick C. Simonds

Day test question
 
The code below ensures that the date selected (on Calendar1) is a Thursday
and works fine. The intent here to create an annual vacation book, and
because of how the book is printed it needs to start on a Thursday.
Calendar1 is set to show the month of January when it opens.

What I need now is some way to amend the code so that if January 1 does not
fall on a Thursday, that they can only select the Thursday prior to January
1.




Sub Thursday_Test()

Dim MyDate, MyWeekDay
MyDate = DVal '= Date selected on Calendar1
MyWeekDay = Weekday(MyDate)

If MyWeekDay = 5 Then
ActiveCell.Value = DVal
Unload Calendar

RenameWorksheets.Rename_Worksheets

Exit Sub

End If
Unload Calendar
WrongDay.Show

End Sub



All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com