ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Age Calculation (https://www.excelbanter.com/excel-programming/423043-age-calculation.html)

kjstec

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

ruic[_2_]

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




Eduardo

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


egun

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



All times are GMT +1. The time now is 01:55 AM.

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