How to generate a unique, alphabetized list of entries from a column of data

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,048
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a table of entries that could be 100+ entries. Column D of that table is the country of origin. It may or may not repeat throughout the table.

I need to generate a list of countries that appear in that column that is (1) unique [no repeats] and (b) preferably alphabetized.

I may have done something like this in the past, but if so I can no longer find it and now have no clue how to start...

Thanks!
 
Hi,

Make name range Country (all country) then use this CSE formula:

=IFERROR(INDEX(Country,SMALL(IF(FREQUENCY(MATCH(Country,Country,0),ROW(Country)-MIN(ROW(Country))+1)>0,ROW(Country)-MIN(ROW(Country))+1,""),ROW($A1))),"")

CSE --> CONTROL+SHIFT+ENTER

Hmmm...didn't work. Got entire list of just the first country in the list. Not sure I did it right. I created a random list of counties, then named the range "Country". Then a couple of columns over I highlighted a vertical range of cells, entered the formula above into the address bar and CONTROL+SHIFT+ENTER.
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi roscoe,

It's been awhile since 6/2016.

That formula should work ... however ...

Then a couple of columns over I highlighted a vertical range of cells, entered the formula above into the address bar and CONTROL+SHIFT+ENTER.

Committing the entire range at once is what is causing this. Try the following to remedy the above.

1.) Select the range in question and delete it.
2.) Now array enter the formula given into the first cell of the intended range only.
3. )Fill down.

As an added thought. Consider changing

Code:
=IFERROR(INDEX(Country,SMALL(IF(FREQUENCY(MATCH(Country,Country,0),ROW(Country)-MIN(ROW(Country))+1) > 0,ROW(Country)-MIN(ROW(Country))+1,""),[B]ROW($A1)[/B])),"")

To
Code:
=IFERROR(INDEX(Country,SMALL(IF(FREQUENCY(MATCH(Country,Country,0),ROW(Country)-MIN(ROW(Country))+1) > 0,ROW(Country)-MIN(ROW(Country))+1,""),[B]ROWS($1:1)[/B])),"")

The ROWS($1:1) argument won't cause problems when inserting or deleting rows above the range. The ROW($A1) argument can.
 
Last edited:
Upvote 0
Thanks, but I did enter it as an array formula with CONTROL+SHIFT+ENTER. I'll try the fill down method but pretty sure that's not the issue as I'm familiar with array formulas.
 
Upvote 0
By the way. That formula will return unique countries, but they won't be sorted. If you are open to helper columns this non-array approach will do both. There is also an array version of this without helpers.

Named ranges are Country, helper1 and helper2.



Excel 2012
ABCD
1Countryhelper1helper2Sorted Unique
2Finland124Argentina
3Yemen3011Austria
4United Kingdom229Canada
5Iceland187Finland
6Greece166France
7United KingdomFALSEFALSEGreece
8FinlandFALSEFALSEIceland
9YemenFALSEFALSENew Zealand
10FinlandFALSEFALSEUnited Kingdom
11Argentina41United States
12YemenFALSEFALSEYemen
13United States2610
14United StatesFALSEFALSE
15New Zealand198
16YemenFALSEFALSE
17Austria72
18GreeceFALSEFALSE
19AustriaFALSEFALSE
20France135
21ArgentinaFALSEFALSE
22GreeceFALSEFALSE
23United StatesFALSEFALSE
24ArgentinaFALSEFALSE
25IcelandFALSEFALSE
26Canada93
27ArgentinaFALSEFALSE
28CanadaFALSEFALSE
29United StatesFALSEFALSE
30AustriaFALSEFALSE
31United KingdomFALSEFALSE
Sheet1
Cell Formulas
RangeFormula
B2=IF(COUNTIF($A$2:A2,A2)=1,COUNTIF(Country,"<="&Country))
C2=IF(B2,RANK(B2,helper1,1))
D2=IFERROR(INDEX(Country,MATCH(ROWS($2:2),helper2,0)),"")
Named Ranges
NameRefers ToCells
Country=Sheet1!$A$2:$A$31
helper1=Sheet1!$B$2:$B$31
helper2=Sheet1!$C$2:$C$31
 
Last edited:
Upvote 0
Here's one way...

Data Range
B
C
D
1
Country​
------​
Uniques​
2
Greece​
China​
3
France​
England​
4
USA​
France​
5
Germany​
Germany​
6
Greece​
Greece​
7
Italy​
Italy​
8
USA​
USA​
9
England​
10
China​
11
China​

This array formula** entered in D2:

=IFERROR(INDEX(B$2:B$11,MATCH(0,COUNTIF(B$2:B$11,"<"&B$2:B$11)-SUM(COUNTIF(B$2:B$11,D$1:D1)),0)),"")

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
 
Upvote 0
Never said thank you but the last option did exactly what I asked for......unfortunately I then discovered that my desire to "update on the fly" was a bad idea. Every edit, every minor change takes 15-25 seconds to recalculate (Which I need because I use conditional formatting to guide my edits) and is driving me CRAZY.

I now think a macro that runs on "file open" and/or "on command" is a better option. I'm going to look at some of the advanced filter ideas that were suggested earlier.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,820
Members
449,469
Latest member
Kingwi11y

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