PDA

View Full Version : Solved: Calculate age from row eleven



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

mdmackillop
07-04-2010, 12:18 PM
If Target.Column = 7 And Target.Row > 10 Then

adamsm
07-04-2010, 12:22 PM
Thanks for the help mdmackillop. Wow. that was easy. I do really appreciate your help.