#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Display Age


I have a spreadsheet in which I have one column where I enter a persons
D.O.B. and in the next column it contains the formula to work out and
display their age, however I'd like to be able to just enter the D.O.B.
and for the age to be calculated and displayed in the same column as the
info is entered, is this at all possible?


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 695
Default Display Age

1 way is:

=NOW()-DATE(1956;11;23)

format cells as custum yy


"sparty" skrev:


I have a spreadsheet in which I have one column where I enter a persons
D.O.B. and in the next column it contains the formula to work out and
display their age, however I'd like to be able to just enter the D.O.B.
and for the age to be calculated and displayed in the same column as the
info is entered, is this at all possible?


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Display Age

sparty,

Not without losing the DOB entry - there is no formatting solution.

Otherwise, you could use an event to overwrite the DOB with the Age formula using the cell entry as
one of the arguments.

HTH,
Bernie
MS Excel MVP


"sparty" wrote in message
...

I have a spreadsheet in which I have one column where I enter a persons
D.O.B. and in the next column it contains the formula to work out and
display their age, however I'd like to be able to just enter the D.O.B.
and for the age to be calculated and displayed in the same column as the
info is entered, is this at all possible?


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Display Age


Thanks Skrev, couldnt get that to work.
Bernie, it doesnt matter if I lose the DOB entry as once calculated all
I want to show is the age and for it to auto update. Could you please
explain your solution a little more thanks.


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Display Age

sparty,

For example, to convert DOB entered into column B, copy the code below, right-click the sheet tab,
and select "View Code" and paste the code into the window that appears.

You may need to change the

Target.NumberFormat = "mm/dd/yyyy"

depending on your Version of Excel. Definitely works in the US....

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub
If Not IsDate(Target.Value) Then Exit Sub
Application.EnableEvents = False
Target.NumberFormat = "mm/dd/yyyy"
Target.Formula = "=DATEDIF(DATEVALUE(""" & Target.Text & """),TODAY(),""y"")"
Target.NumberFormat = "0"
Application.EnableEvents = True
End Sub




"sparty" wrote in message
...

Thanks Skrev, couldnt get that to work.
Bernie, it doesnt matter if I lose the DOB entry as once calculated all
I want to show is the age and for it to auto update. Could you please
explain your solution a little more thanks.


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Display Age

This is a better version - if the column width is too small, the other version gives an error:
Also, the column should be formatted for dates so that IsDate doesn't throw you out....

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub
If Not IsDate(Target.Value) Then Exit Sub
Application.EnableEvents = False
Target.Formula = "=DATEDIF(DATEVALUE(""" & _
Format(Target.Value, "mm/dd/yyyy") & """),TODAY(),""y"")"
Target.NumberFormat = "0"
Application.EnableEvents = True
End Sub


HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
sparty,

For example, to convert DOB entered into column B, copy the code below, right-click the sheet tab,
and select "View Code" and paste the code into the window that appears.

You may need to change the

Target.NumberFormat = "mm/dd/yyyy"

depending on your Version of Excel. Definitely works in the US....

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub
If Not IsDate(Target.Value) Then Exit Sub
Application.EnableEvents = False
Target.NumberFormat = "mm/dd/yyyy"
Target.Formula = "=DATEDIF(DATEVALUE(""" & Target.Text & """),TODAY(),""y"")"
Target.NumberFormat = "0"
Application.EnableEvents = True
End Sub




"sparty" wrote in message
...

Thanks Skrev, couldnt get that to work.
Bernie, it doesnt matter if I lose the DOB entry as once calculated all
I want to show is the age and for it to auto update. Could you please
explain your solution a little more thanks.


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674





  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Display Age


Once again thanks Bernie it works a treat, however theres one problem
I've noticed and that it will only work once so if I delete the
contents of a cell and input data (DOB) again in just displays the
excel number/date value, is there a way round this?


--
sparty
------------------------------------------------------------------------
sparty's Profile: http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Display Age

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub
If Target.Value = "" Then
Target.NumberFormat = "mm/dd/yyyy"
Exit Sub
End If
If Not IsDate(Target.Value) Then Exit Sub
Application.EnableEvents = False
Target.Formula = "=DATEDIF(DATEVALUE(""" & _
Format(Target.Value, "mm/dd/yyyy") & """),TODAY(),""y"")"
Target.NumberFormat = "0"
Application.EnableEvents = True
End Sub


"sparty" wrote in
message ...

Once again thanks Bernie it works a treat, however theres one problem
I've noticed and that it will only work once so if I delete the
contents of a cell and input data (DOB) again in just displays the
excel number/date value, is there a way round this?


--
sparty
------------------------------------------------------------------------
sparty's Profile:
http://www.excelforum.com/member.php...o&userid=31306
View this thread: http://www.excelforum.com/showthread...hreadid=563674



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
pivot table data display in cell sherobot Excel Discussion (Misc queries) 1 June 3rd 06 01:43 AM
how to display subjects taught by a specific teacher upon selection of the teacher name in a drop down box janice fernandes New Users to Excel 5 March 9th 06 12:24 PM
How to display results to certain number of significant figures Coeliac Excel Discussion (Misc queries) 1 January 10th 06 12:04 PM
How do you display Greek and Russian languages in excel? Mark Hayden Excel Discussion (Misc queries) 1 August 1st 05 08:06 AM
Combine & Display “Fixed” & “Automatically Updated” Date Parts texcel Excel Worksheet Functions 1 November 1st 04 05:38 PM


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