Horizontal Unique Formula Needed

BrettOlbrys1

Board Regular
Joined
May 1, 2018
Messages
139
Office Version
  1. 365
Platform
  1. Windows
I need to look horizontally across multiple columns, and return the unique values horizontally as well. For example:

Screenshot 2022-03-16 195045.png


If I look across A2:F2, the unique values would appear in H2:M2. There will only be the six columns of data (A - F), and the results will always appear in the possible six results columns (H - M).

How do I accomplish this?

Thanks

Brett
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try this:
MrExcel_20220315.xlsx
ABCDEFGHIJKLM
1Name 1Name 2Name 3Name 4Name 5Name 6
2BrettGeorgeTomBrettBrettJoeBrettGeorgeTomJoe
3GeorgeBrettTomGregGregGeorgeBrettTomGreg
4GregGeorgeBrettJoeRichTomGregGeorgeBrettJoeRichTom
Sheet4
Cell Formulas
RangeFormula
H2:K2,H4:M4,H3:L3H2=UNIQUE(A2:F2,TRUE)&""
Dynamic array formulas.
 
Upvote 0
I think better to eliminate the blanks rather than having the null string value in cell L3 in the above results. This is particularly so if the list (H3#) is to be used in some other operation later.

22 03 17.xlsm
ABCDEFGHIJKLM
1Name 1Name 2Name 3Name 4Name 5Name 6
2BrettGeorgeTomBrettBrettJoeBrettGeorgeTomJoe
3GeorgeBrettTomGregGregGeorgeBrettTomGreg
4GregGeorgeBrettJoeRichTomGregGeorgeBrettJoeRichTom
Unique
Cell Formulas
RangeFormula
H4:M4,H2:K3H2=UNIQUE(FILTER(A2:F2,A2:F2<>""),TRUE)
Dynamic array formulas.
 
Upvote 0
Thank you, both formulas work and will help me. Now, let me throw one more wrinkle into this, which I should have included in the first post:

The cells in A to F are populated by a lookup and in some case, an actual name may not appear in A:F because that lookup may be blank, and when it is blank, I have populated those blank cells with "UNKNOWN". So applying the formula above, the actual table would look like the new image.

What I would like to happen is that anytime there is an "UNKNOWN" with other names, such as the highlighted UNKNOWN, I want that UNKNOWN to not appear. The only time an UNKNOWN would appear is when it is the only result of the dynamic result.

How do I ignore "UNKNOWN" when it is with other results?
 

Attachments

  • Screenshot 2022-03-17 081734.png
    Screenshot 2022-03-17 081734.png
    62.4 KB · Views: 8
Upvote 0
22 03 17.xlsm
ABCDEFGHIJKLM
1Name 1Name 2Name 3Name 4Name 5Name 6
2BrettGeorgeTomBrettBrettJoeBrettGeorgeTomJoe
3GeorgeBrettTomGregGregUNKNOWNGeorgeBrettTomGreg
4GregGeorgeBrettJoeRichTomGregGeorgeBrettJoeRichTom
Unique
Cell Formulas
RangeFormula
H4:M4,H2:K3H2=UNIQUE(FILTER(A2:F2,(A2:F2<>"")*(A2:F2<>"UNKNOWN")),TRUE)
Dynamic array formulas.



.. or if there will definitely be no blanks in A:F then

22 03 17.xlsm
ABCDEFGHIJKLM
1Name 1Name 2Name 3Name 4Name 5Name 6
2BrettGeorgeTomBrettBrettJoeBrettGeorgeTomJoe
3GeorgeBrettTomGregGregUNKNOWNGeorgeBrettTomGreg
4GregGeorgeBrettJoeRichTomGregGeorgeBrettJoeRichTom
Unique
Cell Formulas
RangeFormula
H4:M4,H2:K3H2=UNIQUE(FILTER(A2:F2,A2:F2<>"UNKNOWN"),TRUE)
Dynamic array formulas.
 
Upvote 0
Another option if you want the "Unknown" to appear on that last row
Excel Formula:
=UNIQUE(FILTER(A2:F2,A2:F2<>"UNKNOWN","UNKNOWN"),TRUE)
 
Upvote 0
Solution
Thanks, but I only cut the image off at row 5, there are 10,000 rows of data and the UNKNOWN that you see in row 5 could be throughout the entire dataset, so it's not the last row. The only time UNKNOWN should appear is when every cell it compared in the row is UNKNOWN, like I show in Row 5.
 
Upvote 0
That is what the formula I posted does. :)
 
Upvote 0
Another option if you want the "Unknown" to appear on that last row
Excel Formula:
=UNIQUE(FILTER(A2:F2,A2:F2<>"UNKNOWN","UNKNOWN"),TRUE)
(y) Ah, I hadn't caught on to that last row requirement. ?
 
Upvote 0

Forum statistics

Threads
1,224,194
Messages
6,177,071
Members
452,760
Latest member
marcoschriek

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