Hi! I'm trying to write a piece of code to calculate the gestational age of expectant mothers based on their estimated due date. This is a first attempt at making a user defined function in excel and I can't seem to figure out why it won't work. Any help you can give would be much appreciated.
Thank you!
Laurie
Function GA(edc As Date, dd As Date, today As Date) As String
'Gestational Age (GA)
If IsMissing(today) Then
today = Date
End If
If IsMissing(edc) Then
GA = ""
Else
Select Case dd
Case IsMissing
GA_Days_Total = 280 + Int(edc - today)
Case Is > today
GA_Days_Total = 280 + Int(edc - dd)
Case Is = today
GA_Days_Total = 280 + Int(edc - dd)
End Select
GA_Weeks = Fix(GA_Days_Total / 7)
GA_days = GA_Days_Total Mod 7
GA = CStr(GA_Weeks) & " " & CStr(GA_days) & "/7 weeks"
End If
End Function
Bookmarks