Check 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)
 
J

joel

from
If Val(Me.TextBox1.Value) > Range("A1") Then
to
If DateValue(Me.TextBox1.Value) > Range("A1") Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top