# Create ordinal numbers for birthday

Post number 2 has been selected as the best answer.

Status
Not open for further replies.

#### gaib

Member
I'm using the age script from here, but have the question, how can I get the ordinal number for the birthdate?

You would need to get the number - then add the ordinal using select case.

Get the last value in the age - and add the ordinal:
Select Case CLng(Right(age, 1))
Case 1
OrdinalAge = age & "st"
Case 2
OrdinalAge = age & "nd"
Case 3
OrdinalAge = age & "rd"
Case Else
OrdinalAge = age & "th"
End Select

Then, to account for the 3 that are different... check if 11, 12, or 13:
Select Case CLng(Right(age, 2))
Case 11, 12, 13
OrdinalAge = age & "th"
End Select
Code:
``````bday = bday + 0.25 ' sets it for 6 am the day of the birthday

age = DateDiff("yyyy", oContact.Birthday, bday)

Select Case CLng(Right(age, 1))

Case 1
OrdinalAge = age & "st"

Case 2
OrdinalAge = age & "nd"

Case 3
OrdinalAge = age & "rd"

Case Else
OrdinalAge = age & "th"

End Select

Select Case CLng(Right(age, 2))
Case 11, 12, 13
OrdinalAge = age & "th"
End Select

Debug.Print age, OrdinalAge

Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

objMsg.Subject = "Happy " & OrdinalAge & " Birthday"
objMsg.Body = "Hope your day is a happy one! May you enjoy the next " & age & " years as much as the last " & age & "!"
objMsg.DeferredDeliveryTime = bday

'displays the message form so you can enter more text
objMsg.Display``````

Thanks again Diane. This worked great.

Status
Not open for further replies.
Thread starter Title Forum Replies Date
Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
How to create a button that sorts and selects the most recent message with ONE click Using Outlook 2
PSA: How to create custom keyboard shortcut for "Paste Unformatted Text" in Outlook on Windows Outlook VBA and Custom Forms 1
Create a Quick Step or VBA to SAVE AS PDF in G:|Data|Client File Outlook VBA and Custom Forms 1
create email only data file Using Outlook 1
Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
How to create a drop down user defined field that will appear on an inbox view Outlook VBA and Custom Forms 8
Any way to create "from-only" account on Outlook 2021? Using Outlook 1
Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
Create new Move To Folder list Outlook VBA and Custom Forms 0
Create Meeting With Custom Form Outlook VBA and Custom Forms 2
Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
Outlook 365 - How to create / copy a new contact from an existing one? Using Outlook 5
Create new email from the received Email Body with attachment Outlook VBA and Custom Forms 10
How to create fixed signatures for aliases that process through GMAIL? Outlook VBA and Custom Forms 0
Can I create a Rule that sends me an email when I get a Task? Using Outlook 2
How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
Can I create a local PST file for SPAM on a drive that is usually disconnected? Using Outlook 3
Create an appointment for all the members Outlook VBA and Custom Forms 1
Create a clickable custom column field Outlook VBA and Custom Forms 0
Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
automaticaly create a teams meeting with a sync Using Outlook 0
Can Exchange Admin Center create a pst for users email/contacts/calendar? Exchange Server Administration 0
Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
How to create phone number as links in notes of Contacts Using Outlook 2
Can't create new appointment Using Outlook 1
Create date folder and move messages daily Outlook VBA and Custom Forms 1
Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
Multiple email accounts - hesitate to create a new profile Using Outlook 3
Can't create Folder Groups in Outlook 2013 Using Outlook 0
Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
Delete/create/reset Exchange mailbox on Outlook.com Using Outlook.com accounts in Outlook 3
Can not create folder to store specific emails in in Outlook for Mac Using Outlook 1
Create Search Folder excluding Specific Email Addresses Using Outlook 5
Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
What tools do you use to create the signature for email? Using Outlook 3
How to create a new email with @outlook.com Using Outlook.com accounts in Outlook 32
Should a new email account also create new contacts Using Outlook 2
create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
Outlook add-in to create new contact from an email. Using Outlook 0
Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
Script to create a pst file for Archiving Using Outlook 1
Can I create a Rule with Or'd conditions? Using Outlook 1
Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
How do I create a custom pick list in VB for an outlook automated email? Outlook VBA and Custom Forms 1
Create Custom Form Using Outlook 0