Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Date Validation for Date of Birth

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Date Validation for Date of Birth

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)

"Stitch45" wrote in message
.uk...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Date Validation for Date of Birth

Probably not necessary. In Windows, go to Control Panel, Regional options,
Customize, Date. There you can choose how Windows interprets 2-digit years.

--
Kind regards,

Niek Otten

"Stitch45" wrote in message
.uk...
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



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
calculate date of birth with an end date and age Tifosa Excel Worksheet Functions 1 January 7th 10 04:03 PM
Birth date from age JP6262AMY Excel Worksheet Functions 2 March 10th 08 06:30 PM
How can I get an age using todays date and date of birth? tjw1313 Excel Discussion (Misc queries) 3 December 3rd 05 01:23 AM
formula to calculate age using birth date and current date lalah Excel Worksheet Functions 2 November 20th 05 10:51 PM


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