adamsm
07-04-2010, 10:56 AM
The following code calculates age when date of birth is written in column "G" of the active worksheet.
How could I make the code to calculate age starting from row 11 onwards.
Any help on this would be kindly appreciated.
Here's the code I've got so far.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 Then
Target.Offset(, 1).Formula = "=IF(DATEDIF(RC[-1],NOW(),""y"")>0,DATEDIF(RC[-1],NOW(),""y"") & "" years"",IF(DATEDIF(RC[-1],NOW(),""m"")>0,DATEDIF(RC[-1],NOW(),""ym"") & "" months"",DATEDIF(RC[-1],NOW(),""y"")))"
End If
End Sub
How could I make the code to calculate age starting from row 11 onwards.
Any help on this would be kindly appreciated.
Here's the code I've got so far.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 Then
Target.Offset(, 1).Formula = "=IF(DATEDIF(RC[-1],NOW(),""y"")>0,DATEDIF(RC[-1],NOW(),""y"") & "" years"",IF(DATEDIF(RC[-1],NOW(),""m"")>0,DATEDIF(RC[-1],NOW(),""ym"") & "" months"",DATEDIF(RC[-1],NOW(),""y"")))"
End If
End Sub