Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validating entered data as date

I ahve some code (A couple Subs) that I use to validate
that the data entered into a specific column of a specific
sheet is numeric, as listed below:::
Sub Auto_Open()
Sheets("Form").OnEntry = "numbers"
End Sub

Sub numbers()
If ActiveCell.Column = 6 And Not IsNumeric
(ActiveCell.Value) Then
MsgBox "Value Must Be A Number."
ActiveCell.Value = "" ' Clears contents of active
cell.
End If
End Sub


What I would like to be able to do is to change the
validation process to make it validdate that the data
entered is a date in mm/dd/yyyy format. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Validating entered data as date

If ActiveCell.Text Like "*/*/????*" And IsDate(ActiveCell.Text) Then
MsgBox "OK"
Else
MsgBox "Not OK"
End If

However, some people might have their system date set as ##-##-## so this would fail. I would personally just use IsDate

e.g.
If IsDate(ActiveCell.Text) Then
MsgBox "OK"
Else
MsgBox "Not OK"
End If

"Mr. B" wrote in message ...
I ahve some code (A couple Subs) that I use to validate
that the data entered into a specific column of a specific
sheet is numeric, as listed below:::
Sub Auto_Open()
Sheets("Form").OnEntry = "numbers"
End Sub

Sub numbers()
If ActiveCell.Column = 6 And Not IsNumeric
(ActiveCell.Value) Then
MsgBox "Value Must Be A Number."
ActiveCell.Value = "" ' Clears contents of active
cell.
End If
End Sub


What I would like to be able to do is to change the
validation process to make it validdate that the data
entered is a date in mm/dd/yyyy format. Any suggestions?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Validating entered data as date

Dates are stored as the number of days since a base date. If excel
recognizes it as a date, then it is converted to that format. You use
formatting to determine how it is displayed. You desire to check how it is
typed in is unwarranted.

--
Regards,
Tom Ogilvy

"Mr. B" wrote in message
...
I ahve some code (A couple Subs) that I use to validate
that the data entered into a specific column of a specific
sheet is numeric, as listed below:::
Sub Auto_Open()
Sheets("Form").OnEntry = "numbers"
End Sub

Sub numbers()
If ActiveCell.Column = 6 And Not IsNumeric
(ActiveCell.Value) Then
MsgBox "Value Must Be A Number."
ActiveCell.Value = "" ' Clears contents of active
cell.
End If
End Sub


What I would like to be able to do is to change the
validation process to make it validdate that the data
entered is a date in mm/dd/yyyy format. Any suggestions?



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
Conditional Formatting according to the date the data is entered hadeeter Excel Discussion (Misc queries) 1 May 6th 10 08:16 PM
static date in new file when data entered in another HELP ME PLEASE Excel Worksheet Functions 2 February 28th 08 03:10 PM
Validating Dates Entered patam Excel Discussion (Misc queries) 2 September 2nd 05 05:36 PM
Validating a date field kenelder Excel Discussion (Misc queries) 2 February 16th 05 10:50 PM
Input Date when data is entered into another cell GaryByrd Excel Worksheet Functions 2 February 1st 05 12:37 AM


All times are GMT +1. The time now is 02:00 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"