#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Check date

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)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Check date

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

"Woodi2" wrote:

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)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Check date

Thanks Joel, you have rescued my code again. Thought i was somewhere near.

"joel" wrote:

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

"Woodi2" wrote:

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)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Check Aaron Excel Programming 1 November 16th 06 11:25 PM
Check date and act on it ladyhawke Excel Programming 6 August 28th 06 08:22 AM
Change text to date and check against date in cell RW Excel Programming 3 February 2nd 06 03:29 PM
Check for date Kjeldc Excel Programming 8 November 30th 05 03:21 AM
Check date Ben Excel Programming 2 December 21st 04 06:18 AM


All times are GMT +1. The time now is 07:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"