Extract unique list of names vertically from a 6*6 matrix( 6 rows and 6 columns)

Jinson

New Member
Joined
Mar 14, 2017
Messages
17
Office Version
  1. 2019
Platform
  1. Windows
Hello !!

I have a matrix of 6*6 with names of all my colleagues. I want to extract the unique names vertically. I'm using Microsoft excel 2019. Also the matrix range is dynamic i.e. it can be 3by3, 7by7, 3by2 ( 3 rows and 2 columns), 2by3 (2 rows and 3 columns) and so on. Looking for a either a power query or a formula solution.

Thanks!!

PS : I already know the trick of using Ctrl + C twice to open clipboard, copy all the names, paste vertically and use remove duplicate feature.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try:
Book1 (2).xlsx
ABCDEFG
1ACBBCUnique
2CCACAA
3BABBCC
4DDBADB
5ABBDAD
6BBBDD 
7 
8 
9 
10 
11 
12 
13 
Sheet2
Cell Formulas
RangeFormula
G2:G13G2=IFERROR(INDIRECT(ADDRESS(INT(AGGREGATE(15,6,IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,ROW($A$1:$E$6),"")+IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,COLUMN($A$1:$E$6)/100,""),1)),MOD(AGGREGATE(15,6,IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,ROW($A$1:$E$6),"")+IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,COLUMN($A$1:$E$6)/100,""),1),1)*100)),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Power Query
Book13
ABCDEFGH
1Column1Column2Column3Column4Column5Column6Value
2SamMary JackLouis AlJoeSam
3Mary LuisAlJoeSimJoanneMary
4JackSamSimHalDonMaryJack
5LouisJoeJimJackHalBillLouis
6Al
7Joe
8Luis
9Sim
10Joanne
11Hal
12Don
13Jim
14Bill
Sheet1


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Trimmed Text" = Table.TransformColumns(#"Removed Columns",{{"Value", Text.Trim, type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Trimmed Text")
in
    #"Removed Duplicates"
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have MS365 you can try the column H formula below (formula only needs to go in cell H2), otherwise try column I (formula needs to be copied down as far as you might need)

21 10 29.xlsm
ABCDEFGHI
1Name 2Name 3Name 3Name 6Name 8Name 9UniqueUnique
2Name 2Name 6Name 2Name 7Name 4Name 6Name 2Name 2
3Name 8Name 7Name 1Name 8Name 5Name 1Name 8Name 3
4Name 9Name 5Name 5Name 3Name 1Name 4Name 9Name 6
5Name 1Name 3Name 1Name 9Name 9Name 1Name 1Name 8
6Name 1Name 8Name 7Name 4Name 5Name 1Name 3Name 9
7Name 6Name 7
8Name 7Name 4
9Name 5Name 1
10Name 4Name 5
11 
12 
Unique List
Cell Formulas
RangeFormula
H2:H10H2=LET(a,A1:F6,r,ROWS(a),seq,SEQUENCE(r*COLUMNS(a),,0),arr,INDEX(a,MOD(seq,r)+1,seq/r+1),UNIQUE(FILTER(arr,arr<>0)))
I2:I12I2=IFERROR(INDIRECT(TEXT(AGGREGATE(15,6,(ROW(A$1:F$6)*10^6+COLUMN(A$1:F$6))/((A$1:F$6<>"")*(ISNA(MATCH(A$1:F$6,I$1:I1,0)))),1),"R000000C000000"),0),"")
Dynamic array formulas.
 
Upvote 0
Solution
Try:
Book1 (2).xlsx
ABCDEFG
1ACBBCUnique
2CCACAA
3BABBCC
4DDBADB
5ABBDAD
6BBBDD 
7 
8 
9 
10 
11 
12 
13 
Sheet2
Cell Formulas
RangeFormula
G2:G13G2=IFERROR(INDIRECT(ADDRESS(INT(AGGREGATE(15,6,IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,ROW($A$1:$E$6),"")+IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,COLUMN($A$1:$E$6)/100,""),1)),MOD(AGGREGATE(15,6,IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,ROW($A$1:$E$6),"")+IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,COLUMN($A$1:$E$6)/100,""),1),1)*100)),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Thank you for your response !! it was very helpful!!
 
Upvote 0
Power Query
Book13
ABCDEFGH
1Column1Column2Column3Column4Column5Column6Value
2SamMary JackLouis AlJoeSam
3Mary LuisAlJoeSimJoanneMary
4JackSamSimHalDonMaryJack
5LouisJoeJimJackHalBillLouis
6Al
7Joe
8Luis
9Sim
10Joanne
11Hal
12Don
13Jim
14Bill
Sheet1


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Trimmed Text" = Table.TransformColumns(#"Removed Columns",{{"Value", Text.Trim, type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Trimmed Text")
in
    #"Removed Duplicates"
Awesome Power Query Solution !! Thank you !! Both Formula and Power Query solution worked for me !!
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have MS365 you can try the column H formula below (formula only needs to go in cell H2), otherwise try column I (formula needs to be copied down as far as you might need)

21 10 29.xlsm
ABCDEFGHI
1Name 2Name 3Name 3Name 6Name 8Name 9UniqueUnique
2Name 2Name 6Name 2Name 7Name 4Name 6Name 2Name 2
3Name 8Name 7Name 1Name 8Name 5Name 1Name 8Name 3
4Name 9Name 5Name 5Name 3Name 1Name 4Name 9Name 6
5Name 1Name 3Name 1Name 9Name 9Name 1Name 1Name 8
6Name 1Name 8Name 7Name 4Name 5Name 1Name 3Name 9
7Name 6Name 7
8Name 7Name 4
9Name 5Name 1
10Name 4Name 5
11 
12 
Unique List
Cell Formulas
RangeFormula
H2:H10H2=LET(a,A1:F6,r,ROWS(a),seq,SEQUENCE(r*COLUMNS(a),,0),arr,INDEX(a,MOD(seq,r)+1,seq/r+1),UNIQUE(FILTER(arr,arr<>0)))
I2:I12I2=IFERROR(INDIRECT(TEXT(AGGREGATE(15,6,(ROW(A$1:F$6)*10^6+COLUMN(A$1:F$6))/((A$1:F$6<>"")*(ISNA(MATCH(A$1:F$6,I$1:I1,0)))),1),"R000000C000000"),0),"")
Dynamic array formulas.
Hello Peter, Thank you for your response and suggestion !! Have done the needful for future reference !!

PS : Actually I had highlighted in the query that I use Microsoft Excel 2019 :)
 
Upvote 0
PS : Actually I had highlighted in the query that I use Microsoft Excel 2019 :)
Indeed you had and I missed it even though bold. :oops:
I guess I am just so used to looking here
1635509514900.png

Anyway, thanks for updating your details.

Given that version, if you did want to go for a formula version, the one I posted in column I of my mini-sheet is considerably simpler than the one you appear to have chosen. :)
 
Upvote 0
Indeed you had and I missed it even though bold. :oops:
I guess I am just so used to looking here
View attachment 50107
Anyway, thanks for updating your details.

Given that version, if you did want to go for a formula version, the one I posted in column I of my mini-sheet is considerably simpler than the one you appear to have chosen. :)
I'm sorry Peter, I believe I should have clarified that the solution posted by fellow member considered the dynamic aspect of the question I had. The dynamic aspect was that the matrix is dynamic and can changed orientation from being 6*6 to say 3by2 ( 3 rows and 2 columns) or 4by3( 4 rows and 2 columns ) and so on. I would like to humbly point out that the solution suggested by you considered the fixed aspect of only a 6*6 matrix ((ROW(A$1:F$6)*10^6).

If my interpretation is incorrect please correct me !!.
 
Upvote 0
If my interpretation is incorrect please correct me !!.
Your interpretation that my formula was written for a 6x6 grid is correct.
I think that your interpretation that the longer formula would work for any size grid is incorrect as in the formula it explicitly uses $A$1:$E$6 (a 5x6 grid) several times in the formula.

Below I have copied the exact mini-sheet to a blank worksheet and added a 6th column to the data and you will see that none of those values appear in the list.

Have I mis-interpreted what you were getting at?

BTW, there is one other small difference between the formulas. If there happens to be any blank cells in the range, my formula ignores them whereas the other formula will report that as a "0" unique value. Not sure if blanks are possible with your data and if so how you would want them treated.

21 10 29.xlsm
ABCDEFG
1ACBBCUUnique
2CCACAVA
3BABBCWC
4DDBADXB
5ABBDAYD
6BBBDDZ 
7 
8 
9 
10 
11 
12 
13 
Unique List (2)
Cell Formulas
RangeFormula
G2:G13G2=IFERROR(INDIRECT(ADDRESS(INT(AGGREGATE(15,6,IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,ROW($A$1:$E$6),"")+IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,COLUMN($A$1:$E$6)/100,""),1)),MOD(AGGREGATE(15,6,IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,ROW($A$1:$E$6),"")+IF(COUNTIF($G$1:G1,$A$1:$E$6)=0,COLUMN($A$1:$E$6)/100,""),1),1)*100)),"")
 
Upvote 0

Forum statistics

Threads
1,215,177
Messages
6,123,475
Members
449,100
Latest member
sktz

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