Calculate ordinal number of replicates

arvnranger

New Member
Joined
Apr 15, 2007
Messages
7
I have a list of alphanumeric codes. Ideally these should be unique but I find there are duplicates, sometimes 3 of each value. I can use COUNTIF to find the number of instances per code. Is there a function or combination of functions I can use to calculate whether each value is the first, second or third instance of that code in the list, eg

A123,1
B456,1
B987,1
A123,2
C789,1
C345,1
A123,3
B987,2

Cheers,
Ivan.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Is this what you need?

=COUNTIF(A$1:A1,A1)
Or, if your title meant to suggest you actually wanted the ordinal suffix attached to the number...

=COUNTIF(A$1:A1,A1)&MID("thstndrdth",MIN(9,2*RIGHT(COUNTIF(A$1:A1,A1))*(MOD(COUNTIF(A$1:A1,A1)-11,100)>2)+1),2)
 
Upvote 0
Or, if your title meant to suggest you actually wanted the ordinal suffix attached to the number...

=COUNTIF(A$1:A1,A1)&MID("thstndrdth",MIN(9,2*RIGHT(COUNTIF(A$1:A1,A1))*(MOD(COUNTIF(A$1:A1,A1)-11,100)>2)+1),2)

Excellent! Thanks, Tetra201 and Rick. Just had to make one end of the range relative to get a running count... so simple I feel a bit of a ninny.

Cheers,
Ivan.
 
Upvote 0

Forum statistics

Threads
1,216,748
Messages
6,132,492
Members
449,730
Latest member
SeanHT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top