Create ordinal number format in Excel

Anonymous
2010-08-09T14:55:38+00:00

Hello,

I am wondering if anyone knows (or knows of any resources that describe) how to create an ordinal number format in MS Excel.

I am well aware of how to reformat numbers as text to create the ordinal number effect, but what I would like to do is have the numberdisplay as an ordinal number (e.g., "1st", "2nd", "3rd", etc.) while still retaining its numeric value (1, 2, 3, etc.).

The reason for this request is to be able to perform numeric functions (e.g., MIN, MAX, AVERAGE, etc.) on an array of ordinal numbers.

I have a spreadsheet that lists various athletes' scores and the ranking for each score.  I would like to be able to easily determine, for example, each athlete's best ranking by using a MIN() function on the list of ordinal numbers.  Currently the only way I can think to do this is by having the rankings as regular cardinal numbers.

I suppose it would be possible to have an adjacent, hidden column with the numeric value of each ranking, but I thought it might be more elegant if there was a way to change the format of the number without changing its value.

Any help is much appreciated!

Regards,

Craig

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

58 answers

Sort by: Oldest
  1. Anonymous
    2011-02-28T16:21:37+00:00

    Had this been last week I would have proposed Adam's Solution as the answer.

    The problem with Adam's solution is all computer using the workbook its applied to must be version XL2007 or later... those using XL2003 or earlier cannot make use of it.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-03-01T17:51:19+00:00

    - backward compatability - valid point... from a community perspective I can see that a backward compatible solution would be required for earlier version of Excel. 

    However, Craig has not indicated that backward compatability was an issue, so for simplicity and the closest match to the original request then Adam's solution is the the most elegant answer for Ex'07 +

    Just my view, of course.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-04-14T20:21:32+00:00

    This formula will find the string value in I2 in array C3:C385 and display its position in the array as a text string with the proper ordinal ending using nested IF statements.

    =IF(I2="","",IF(MATCH(I2,C3:C385,0)=1,"1st",IF(MATCH(I2,C3:C385,0)=2,"2nd",IF(MATCH(I2,C3:C385,0)=3,"3rd",MATCH(I2,C3:C385,0)&"th"))))

    Was this answer helpful?

    0 comments No comments
  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  5. Paul Edstein 82,871 Reputation points Volunteer Moderator
    2011-04-16T04:57:42+00:00

    The following UDF, when combined with a modification of Rick Rothstein's event code (supplied), can be used to express the value in any cell as an ordinal:

    Function Ordinal(ByVal Num As Long) As Long

    Ordinal = Num

    End Function

    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Cell As Range

    For Each Cell In Target

      If UCase(Cell.Formula) Like "=ORDINAL(?*)" Then

      Cell.NumberFormat = "#""" & Mid$("thstndrdthththththth", 1 - 2 * _

        ((Cell.Value) Mod 10) * (Abs((Cell.Value) Mod 100 - 12) > 1), 2) & """"

    End If

    Next

    End Sub

    To use it, simply input a formula into a cell as, for example:

    =Ordinal(A1) or =Ordinal(37)

    The underlying values remain available for use as numbers in other formulae.

    Of course, if only a limited range of cells in a large workbook can have this kind of formula, it would be wise to narrow the event's target range to just that. Unlike Rick's event-driven macro, the above approach allows a mix of ordinal and ordinary values to coexist in the target range.

    Was this answer helpful?

    0 comments No comments