Sub Button3_Click()
For I = 8 To 15
If Weekday(Cells(I, 2).Value) = 1 Then
MsgBox "invalid date"
End If
Next I
For I = 8 To 15
If Weekday(Cells(I, 2).Value) = 7 Then
MsgBox "invalid date"
End If
Next I
End Sub
Jose,You could use Data Validation for this, and have an error window pop up if a "non-weekday" is input. The data validation formula would be as below (assumes date is input in cell A1)
=AND(WEEKDAY(A1)>1,WEEKDAY(A1)<7)
Are you sure your dates are entered as "Date" and not "Text"?for some reason, every cell is an invalid date...
Are you sure your dates are entered as "Date" and not "Text"?
What are some of your date values?
Are they entered in cells B8, B9, B10, etc?
Sub Button3_Click()
For I = 8 To 15
If Weekday(Cells(I, 2).Value, 2) > 6 Then
MsgBox "Cell: " & Cells(I, 2).Address & vbCrLf & _
"Value: " & Cells(I, 2).Value & vbCrLf & _
"Is valid date?: " & IsDate(Cells(I, 2).Value) & vbCrLf & _
"Message: invalid date"
End If
Next I
End Sub