wordperfectconvert
Technical User
I was referred from VBA forum to this forum. I have a table where B1 ( named B1 "Sex") asks for sex ("male" or "female") and B2 asks for Date of Birth. B3 (named "Age") calculates the persons age. B4 has been named "LifeExpectancy". I have to use a specific mortality table for my purposes. I have ages from 1 to 80. That will give me about 160 different results. I tried If statements in a cell, but was limited by the number of If statements I can use.
The formula I used so far is a formula to calculate Age for B3, as:
Function Age1(DOB As Date)
If DOB = 0 Then
Age1 = "No Birthdate"
Else
Select Case Month(Date)
Case Is < Month(DOB)
Age1 = Year(Date) - Year(DOB) - 1
Case Is = Month(DOB)
If Day(Date) >= Day(DOB) Then
Age1 = Year(Date) - Year(DOB)
Else
Age1 = Year(Date) - Year(DOB) - 1
End If
Case Is > Month(DOB)
Age1 = Year(Date) - Year(DOB)
End Select
End If
End Function
THIS GETS ME THE AGE.
I am now trying to say something like If Sex = Male and Age = 47 then LifeExpectancy = 36.45. I truly am stumped. I have been surfing the net and trying different options for over 30 hours and am seeing double. Any help would be greatly appreciated. Thank you in advance.
The formula I used so far is a formula to calculate Age for B3, as:
Function Age1(DOB As Date)
If DOB = 0 Then
Age1 = "No Birthdate"
Else
Select Case Month(Date)
Case Is < Month(DOB)
Age1 = Year(Date) - Year(DOB) - 1
Case Is = Month(DOB)
If Day(Date) >= Day(DOB) Then
Age1 = Year(Date) - Year(DOB)
Else
Age1 = Year(Date) - Year(DOB) - 1
End If
Case Is > Month(DOB)
Age1 = Year(Date) - Year(DOB)
End Select
End If
End Function
THIS GETS ME THE AGE.
I am now trying to say something like If Sex = Male and Age = 47 then LifeExpectancy = 36.45. I truly am stumped. I have been surfing the net and trying different options for over 30 hours and am seeing double. Any help would be greatly appreciated. Thank you in advance.