ORDINAL
ORDINAL(n)
Returns a number with its corresponding ordinal abbreviation.
| n |
REMARKS
??
Public Function Ordinal( _
n As Long) _
As String
Dim suffix As String
Dim lastTwo As Long
Dim lastDigit As Long
lastTwo = n Mod 100
lastDigit = n Mod 10
' Handle special cases: 11th, 12th, 13th
If lastTwo >= 11 And lastTwo <= 13 Then
suffix = "th"
Else
Select Case lastDigit
Case 1: suffix = "st"
Case 2: suffix = "nd"
Case 3: suffix = "rd"
Case Else: suffix = "th"
End Select
End If
Ordinal = CStr(n) & suffix
End Function
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext