Date Validation

HarryT

New Member
Joined
Jun 1, 2006
Messages
35
I have a column of dates, I want to validate that the date given is valid as well as validate that someone did not enter alpha characters... Sometimes someone will enter N/A in the field for some reason.

I am trying to validate a file which already has the dates entered in the columns. I was looking to validate each cell through VB, but can't seem to figure out the syntax for the validation.

Any help is much appreciated.

Thanks
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I am trying to validate a file which already has the dates in entered. I was looking to validate each cell through VB, but can't seem to figure out the syntax for the validation.
 
Upvote 0
Try this - it is for column A and will color non-dates red. It isn't perfect.

Code:
Sub ValiDate()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    With Range("A" & i)
        If Not IsDate(.Value) Then .Interior.ColorIndex = 3
    End With
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top