ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change year value in a date column... (https://www.excelbanter.com/excel-programming/339598-change-year-value-date-column.html)

bushtor

Change year value in a date column...
 
Hi,

I have two adjacent columns, one with date values displayed like
DD.MM.YYYY and another with only the two last digits in a year value.
Example:

03.12.2005 89
11.05.2005 67
31.01.2005 93

I need to replace the first column's year value with the second
column's value + 1900. Result wanted:

03.12.1989
11.05.1967
31.01.1993

many years ago I did some excel scripting but I'm definately not
capable of solving this now. Thanks a lot if anyone have a minute to
show me a macro which solves this issue

best regards

tor


Norman Jones

Change year value in a date column...
 
Hi Bushtor,

Try:
'=====================.
Sub Tester()
Dim rng As Range
Dim rCell As Range

Set rng = Range("A1:A10") '<<========= CHANGE

For Each rCell In rng.Cells
If IsDate(rCell) Then
With rCell
.Value = DateSerial(rCell(1, 2).Value, _
Month(.Value), Day(.Value))
End With
End If

Next

End Sub
'=====================.

---
Regards,
Norman



"bushtor" wrote in message
oups.com...
Hi,

I have two adjacent columns, one with date values displayed like
DD.MM.YYYY and another with only the two last digits in a year value.
Example:

03.12.2005 89
11.05.2005 67
31.01.2005 93

I need to replace the first column's year value with the second
column's value + 1900. Result wanted:

03.12.1989
11.05.1967
31.01.1993

many years ago I did some excel scripting but I'm definately not
capable of solving this now. Thanks a lot if anyone have a minute to
show me a macro which solves this issue

best regards

tor





All times are GMT +1. The time now is 11:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com