# Need a formula to sort/index/count - help!

#### cr2crf

##### New Member
I have a spreadsheet with names in column a. Many of the names are duplicates. What I am trying to do is find a way to sort them so that the names can be listed once with a corresponding number to the cell to the right telling me how many times the name is used.

Example:

Column A:
smith
jones
smith
smith
jones
jones
Williams
Barns
Smith
Williams

I want columns B and C to look like this:
smith 4
jones 3
williams 2
barns 1

Thanks

### Excel Facts

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Given in A1 of sheet 'cr2crf':
 smith smith 4 jones jones 3 smith Williams 2 smith Barns 1 jones jones Williams Barns smith Williams

<tbody>
</tbody>

name range cr2cr =ROW('cr2crf '!\$A\$1:\$A\$1500)-ROW('cr2crf '!\$A\$1)+1 change range to fit your model
formula in B1 is =IFERROR(INDEX(\$A\$1:\$A\$390,SMALL(IF(FREQUENCY(IF(\$A\$1:\$A\$390<>"",MATCH("~"&\$A\$1:\$A\$390,\$A\$1:\$A\$390&"",0)),cr2cr),cr2cr),ROWS(\$B\$1:B1))),"") Ctrl + Shift + Enter not just enter on a PC or Command + Return on a MAC.
formula in C1 is =IF(B1="","",COUNTIF(\$A\$1:\$A\$1500,B1)) copied down till needed.

Would that be close to what you required?

I refreshed before I posted my solution, but after posting I see Cyrilbrd had a post 9 minutes before me so I removed mine.

Last edited:
Given in A1 of sheet 'cr2crf':
 smith smith 4 jones jones 3 smith Williams 2 smith Barns 1 jones jones Williams Barns smith Williams

<tbody>
</tbody>

name range cr2cr =ROW('cr2crf '!\$A\$1:\$A\$1500)-ROW('cr2crf '!\$A\$1)+1 change range to fit your model
formula in B1 is =IFERROR(INDEX(\$A\$1:\$A\$390,SMALL(IF(FREQUENCY(IF(\$A\$1:\$A\$390<>"",MATCH("~"&\$A\$1:\$A\$390,\$A\$1:\$A\$390&"",0)),cr2cr),cr2cr),ROWS(\$B\$1:B1))),"") Ctrl + Shift + Enter not just enter on a PC or Command + Return on a MAC.
formula in C1 is =IF(B1="","",COUNTIF(\$A\$1:\$A\$1500,B1)) copied down till needed.

Would that be close to what you required?

I appreciate your work but Im new to this and don't quite know "range range cr2crf"

I appreciate your work but Im new to this and don't quite know "range range cr2crf"
No worries.
Name Ranges are explained here: click on this link.
If you have difficulties just let us know.
In a nutshell:

1. Choose Insert>Name>Define
2. Type a name for the range, e.g. cr2cr instead of Namelist as seen in the picture

3. In the Refers To box, enter an Offset formula that defines the range size, based on the number of items in the column, e.g.:
=ROW('cr2crf '!\$A\$1:\$A\$1500)-ROW('cr2crf '!\$A\$1)+1 instead of =OFFSET(Sheet1!\$A\$1,0,0,COUNTA(Sheet1!\$A:\$A),1) as seen above...
4. Click OK

I refreshed before I posted my solution, but after posting I see Cyrilbrd had a post 9 minutes before me so I removed mine.
No worries Bruce...

Replies
1
Views
171
Replies
2
Views
662
Replies
8
Views
330
Replies
7
Views
253
Replies
3
Views
157

1,211,803
Messages
6,104,073
Members
447,892
Latest member

### 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.

### Which adblocker are you using?

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

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