Skip to content

Monthly Archives: December 2014

Get the NumSuffix(English)

29-Dec-14

Function OrdinalSuffix(ByVal Num As Long) As String
Dim n As Long
Const cSfx = “stndrdthththththth” ‘ 2 char suffixes
n = Num Mod 100
If ((Abs(n) = 10) And (Abs(n) <= 19)) _ Or ((Abs(n) Mod 10) = 0) Then OrdinalSuffix = "th" Else OrdinalSuffix = Mid(cSfx, _ ((Abs(n) Mod 10) * 2) - 1, 2) End If End Function Function NumSuffix(MyNum As Variant) As String '******************************************* 'Purpose: Add suffix to a number 'Inputs: ? NumSuffix(234) 'Output: 234th '******************************************* Dim n As Integer Dim x As Integer Dim strSuf As String n = Right(MyNum, 2) x = n Mod 10 strSuf = Switch(n <> 11 And x = 1, “st”, n 12 And x …