Handy VBA To Calculate Person Age

This handy VBA procedure is just to show you how we can calculate and display someone Age. To do this, of course we need to know their date of birth first, then simply using datediff and mod vba functions we can calculate how old is he/she.

Sub PersonAge()
    Dim iYears As Integer, iMonths As Integer, iMonth As Integer
    Dim dtDateofbirth As Date

    dtDateofbirth = _
    CDate(InputBox("Input your date of birth (yyyy-mm-dd)", "Date of birth"))

    iYears = DateDiff("yyyy", CDate(dtDateofbirth), Date)
    iMonths = (DateDiff("m", CDate(dtDateofbirth), Date)) Mod (iYears * 12)

    MsgBox "Your age are " & iYears & " year(s) and " & iMonths & " month(s)"
End Sub

For this example, I use MsgBox and InputBox to get input and display the output data, but we can change it to worksheet cells reference if we want to integrate this calculation in our Excel Worksheet.

This entry was posted in Excel VBA Function and tagged , , . Bookmark the permalink.

1,577 Responses to Handy VBA To Calculate Person Age

  1. Pingback: klonopin

  2. Pingback: Ephedrin Kanada

  3. Pingback: Mehr Infos

  4. Pingback: buy scrapebox list

  5. Pingback: GPT Surf

  6. Pingback: Queens Carpet Cleaners

  7. Pingback: learn about it support denver

  8. Pingback: The phone lookup

  9. Pingback: Vij De Video

  10. Pingback: outdoor gazebo

  11. Pingback: Blitz Media Marketing

  12. Pingback: payday loans online

  13. Pingback: read this

  14. Pingback: usb breathalyzer

  15. Pingback: www.easyloanfast.com

  16. Pingback: free quotes about life

  17. Pingback: link

  18. Pingback: h2go

  19. Pingback: costco coupon site

  20. Pingback: Symbol LS 4278 Barcode Scanner

  21. Pingback: crucifix

  22. Pingback: servis char

  23. Pingback: check this out

  24. Pingback: diabetic bags

  25. Pingback: alpharetta tree removal

  26. Pingback: visit site

  27. Pingback: free standing boxing bag

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>