ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validate date in Excel as weekday (https://www.excelbanter.com/excel-programming/417993-validate-date-excel-weekday.html)

TCUser

Validate date in Excel as weekday
 
I am trying to find a way to validate a date entered in Excel as a weekday.
It would be helpful to warn the user if they try to enter a Saturday or
Sunday date and possible holidays.



DMoney

Validate date in Excel as weekday
 
Dim mydate As String
mydate = Format(Date + 2, "dddd")
If mydate = "Saturday" Then msgbox="Saturday Entered"
If mydate = "Sunday" Then msgbox = "Sunday Entered"

"TCUser" wrote:

I am trying to find a way to validate a date entered in Excel as a weekday.
It would be helpful to warn the user if they try to enter a Saturday or
Sunday date and possible holidays.



Gary Keramidas

Validate date in Excel as weekday
 
you don't really give an example of what you're doing, but here is one way,
with the date entered in A1

If Weekday(Range("A1").Value, vbMonday) 5 Then
MsgBox "weekend"
End If

--


Gary

"TCUser" wrote in message
...
I am trying to find a way to validate a date entered in Excel as a weekday.
It would be helpful to warn the user if they try to enter a Saturday or
Sunday date and possible holidays.






All times are GMT +1. The time now is 04:39 PM.

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