Results 1 to 10 of 10

Please help me with a simple VBA function

Threaded View

  1. #1
    Registered User
    Join Date
    10-17-2006
    Posts
    5

    Please help me with a simple VBA function

    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
    Last edited by laurieb; 10-17-2006 at 10:12 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1