RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 788
- Office Version
- 2010
- Platform
- Windows
Have been looking at existing threads on this as well as on other forums, I thought for sure this would work...
So there's four eventualities. The user is prompted to enter a week commencing date.
1) User cancels - end the sub
2) User enters blank - end the sub
3) User enters date that is not a Monday - end the sub
4) User enters a correct date - continue the sub
The first thing that happens is the user will enter a date, say "09/11/2020" - it will make sure this is read as "09 Nov 2020" and not "11 Sep 2020"
What's happening so far is that if I dim wcex as String, if the string is blank or incorrect, it alerts them as it should, but it continually claims that 09/11/2020 is not a Monday, even though it is.
So if I dim wcex as a Date, then the Monday check works perfectly, but if I enter a blank date or cancel, I get a "Type mismatch"
Any ideas on how I can get all four eventualities input? What about a 5th one, if they enter text? Thanks!
VBA Code:
Dim wcex As Date
wcex = InputBox("Choose a Week Commencing Data in 'dd/mm/yyyy' format only", "Enter Week Commencing Data to Export")
wcex = Format(wcex, "dd/mm/yyyy")
If StrPtr(wcex) = 0 Then
MsgBox ("Cancelled - Ending Process")
Exit Sub
ElseIf Len(wcex) = 0 Then
MsgBox ("No input - Ending Process")
Exit Sub
ElseIf Not WorksheetFunction.Weekday(wcex) = 2 Then
MsgBox ("The chosen date of " & wcex & " is not a Monday, try harder")
Exit Sub
Else
MsgBox ("The week " & wcex & " will now export to the Studio Folder")
End If
So there's four eventualities. The user is prompted to enter a week commencing date.
1) User cancels - end the sub
2) User enters blank - end the sub
3) User enters date that is not a Monday - end the sub
4) User enters a correct date - continue the sub
The first thing that happens is the user will enter a date, say "09/11/2020" - it will make sure this is read as "09 Nov 2020" and not "11 Sep 2020"
What's happening so far is that if I dim wcex as String, if the string is blank or incorrect, it alerts them as it should, but it continually claims that 09/11/2020 is not a Monday, even though it is.
So if I dim wcex as a Date, then the Monday check works perfectly, but if I enter a blank date or cancel, I get a "Type mismatch"
Any ideas on how I can get all four eventualities input? What about a 5th one, if they enter text? Thanks!