Check date

  • Thread starter Thread starter Woodi2
  • Start date Start date
W

Woodi2

I would like a code that checks that a date enetered is not greater than
todays date. In Cell A1 i have an autosum NOW() that displays todays date.
I have some code below that i have tried to manipulate from elswhere but its
not working.
A userform opens and i want the date in textbox 1 to be checked to ensure it
is no greater than todays date. Am i anywhere near and also can code be used
to check against an autosum value?

Do
If IsDate(Me.TextBox1.Value) Then
If Val(Me.TextBox1.Value) > Range("A1") Then
MsgBox "date cannot be greater than today's date"
Me.TextBox1.SetFocus
Exit Sub
End If
Else
MsgBox ("Bad Value")
End If
Loop While Not IsDate(Me.TextBox1.Value)
 
from
If Val(Me.TextBox1.Value) > Range("A1") Then
to
If DateValue(Me.TextBox1.Value) > Range("A1") Then
 
Back
Top