Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Age Calculation

I know how to calculate ages such as =YEAR(P327)-YEAR(D327). However, here
is my problem:

I have four columns:
One is the date of birth of the patient
Another is date patient screeded
The next is date patient randomized
The last is age at randomization

Not all patients get randomized. All patients must be screened, but I only
want the age shown if the patient was randomized. If I copy the formula down
the column, it also grabs the blank field in the randomized column and
returns a erroneous age. How can I fix this so that if a randomized field is
blank, the age at randomization cell will also be blank?

Any help is greatly appreciated.

Thanks,
Kathy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Age Calculation

you need to use an IF statement:

If randomized cell isblank then do nothing else calculate age.

isblank is an actuall excel function also.

I'll leave the details to you.

"kjstec" wrote in message
...
I know how to calculate ages such as =YEAR(P327)-YEAR(D327). However, here
is my problem:

I have four columns:
One is the date of birth of the patient
Another is date patient screeded
The next is date patient randomized
The last is age at randomization

Not all patients get randomized. All patients must be screened, but I
only
want the age shown if the patient was randomized. If I copy the formula
down
the column, it also grabs the blank field in the randomized column and
returns a erroneous age. How can I fix this so that if a randomized field
is
blank, the age at randomization cell will also be blank?

Any help is greatly appreciated.

Thanks,
Kathy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,276
Default Age Calculation

Hi,
you can use an if Statement, suppose that the date patient randomized is in
column C

=if(C237="","",(YEAR(P327)-YEAR(D327)), this will leave the cell blank if
C237 is blank

"kjstec" wrote:

I know how to calculate ages such as =YEAR(P327)-YEAR(D327). However, here
is my problem:

I have four columns:
One is the date of birth of the patient
Another is date patient screeded
The next is date patient randomized
The last is age at randomization

Not all patients get randomized. All patients must be screened, but I only
want the age shown if the patient was randomized. If I copy the formula down
the column, it also grabs the blank field in the randomized column and
returns a erroneous age. How can I fix this so that if a randomized field is
blank, the age at randomization cell will also be blank?

Any help is greatly appreciated.

Thanks,
Kathy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Age Calculation

You simply wrap your formula in an IF statement:

=IF(C327="","",YEAR(P327)-YEAR(D327))

assuming C327 holds the randomization cell. If C327 is blank, then the age
cell is left blank also.

For trivia's sake, this formula will calculate age to the nearest day:

=IF(DATEDIF($A2,NOW(),"y")<10," ","") & DATEDIF($A2,NOW(),"y") & " years, "
& IF(DATEDIF($A2,NOW(),"ym")<10," ","") & DATEDIF($A2,NOW(),"ym") & " months,
" & IF(DATEDIF($A2,NOW(),"md")<10," ","") & DATEDIF($A2,NOW(),"md") & " days"

HTH,

Eric

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
Multi threaded calculation (multi CPU) - impact on calculation spe Pascal[_2_] Excel Discussion (Misc queries) 1 December 3rd 08 10:46 AM
Calculation Abilio Excel Programming 0 December 5th 05 02:57 PM
How do I use a rounded calculation result in another calculation? vnsrod2000 Excel Worksheet Functions 1 January 26th 05 10:11 PM
How do I use a rounded calculation result in another calculation? vnsrod2000 Excel Worksheet Functions 1 January 26th 05 09:36 PM
range.calculation with UDF not working when calculation is set to automatic Brian Murphy Excel Programming 5 October 14th 03 07:02 PM


All times are GMT +1. The time now is 08:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"