Excel VBA UserForm TextBox - Learn how to check if date is valid (on click)
The code used in this video:
Private Sub cbOk_Click()
If Not IsDate(txtDate) Then
MsgBox "Please enter a valid date", vbCritical
With txtDate
.SelStart = 0
.SelLength = Len(txtDate)
.SetFocus
End With
Exit Sub
End If
MsgBox "Date OK"
End Sub
Ещё видео!