Date Validation for Date of Birth

  • Thread starter Thread starter Stitch45
  • Start date Start date
S

Stitch45

I receive weekly excel files where the Date of Birth is shown as 01-Jan-26
for example, but when formatted to dd/mm/yyyy the data actually shows the
year as 2026. Can someone help with a VBA script that I can add to my
macro to correct these years to 1900s.

If activecell.value > Year(Now) then
activecell.value = ???

Any help/other suggestions appreciated

thanks
 
Give this a try


iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 To iLastRow
With Cells(i,"A")
If IsDate(.Value) Then
If .Value > Date Then
.Value = DateSerial(Year(.Value -1000), Month(.value),
Day(.Value))
End If
End If
End With
Next i

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Probably not necessary. In Windows, go to Control Panel, Regional options,
Customize, Date. There you can choose how Windows interprets 2-digit years.
 

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

VB Date Format 8
Date Range Macro 2
Excel is changing date format incorrectly 7
MACROS DATES 4
Dates converted into text 5
INPUTBOX QUERY-DATE 1
dd/mm converted to mm/dd 4
Age computation 1

Back
Top