Unique formula based on a column with repeated data

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I've got a list of repeated addresess in column A of a spreadsheet.

But I need to return a unique consecutive list of the addresses in column A, into column G.

In the simple list below, I have 4 countries (England, Japan, Canada and the USA) listed 3 times each. So there are 12 rows in column A, with the countries starting in cell A2.

However, I need to put a formula in column G2 which will list the unique countries and show the results in the 'Unique List of Locations' in column G below.

I'll also need to be able to clear the data from row 3 and below, the be able to drag down the formula in column G when new data is put into the file.

Does anyone know how to do this, please?
LocationsUnique List of Locations
EnglandEngland
EnglandJapan
EnglandCanada
JapanUSA
Japan
Japan
Canada
Canada
Canada
USA
USA
USA
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
As you have office / excel 365, you could use the UNIQUE function if you have it.

 
Upvote 0
Ok.

I tried this, but it didn't work?

Any ideas on how to change it?

=UNIQUE(A2:A13,TRUE)
 
Upvote 0
Try with this at G2.

=IFERROR(INDEX($A$2:$A$12, MATCH(0, INDEX(COUNTIF($g$1:g1, $A$2:$A$12), 0, 0), 0)), "")
 
Upvote 0
Just use
Excel Formula:
=UNIQUE(A2:A13)
You are telling it to return unique cols & you only have one column.
 
Upvote 0
Reading the link that I posted, I would say

=UNIQUE(A2:A13)

I might be reading it wrong, but the TRUE argument appears to be used to return a list of entries that are unique (only appear once in the source list) not to show a list of distinct results.
edit:- I was reading it wrong, that is with 2 commas, not one.
 
Upvote 0
Ok, thanks @mehidy1437 , @Fluff and @jasonb75

Your suggested solutions worked!

I do have two further questions, however.

With the real data, the number of rows will vary with each file.

So I was planning to use =unique(a2:a1000) as there won't ever be more than 1,000 rows.

However, if I extend the number of rows in the example I gave above ie dragging the word 'USA' in cell A13 down until cell A20, then going to cell G2 and typing in =UNIQUE(A2:A1000) I get a #SPILL! error.

Does anyone know why that would happen?

And is there a way to modify the formula in cell G2 using VBA so that it only goes up to the number of rows in column A each time new data is pasted into column A?

I'm sure @Fluff knows how to do that!
 
Upvote 0
You don't need vba for that, just make the range dynamic, either by formula or by using a table. There might be a neater method with 365 that I don't know of.

=UNIQUE($A$2:INDEX($A:$A,MATCH("zzz",$A:$A)))

I believe that #SPILL! means that there are not enough consecutive empty cells where you have entered the formula for it to return all of the results, again, this is not something that I know for certain, just my (perhaps incorrect) understanding of the problem based on things that I've read in other threads.
 
Upvote 0
If you will never have more than 1000 rows you can use
Excel Formula:
=UNIQUE(FILTER(A2:A1000,A2:A1000<>""))
which will prevent getting a 0 in the list.
As Jason has said, the Spill error is because there is a non blank cell in col G preventing the formula from spilling down far enough.
 
Upvote 0
Ok, thank you both!

Both suggestions worked!

I didn't know that #SPILL errors occur because of non-blank cells below - so that info is useful! I came across it for the first time a few days ago!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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