TextJoin without duplicates

Shwapx

New Member
Joined
Sep 28, 2022
Messages
48
Office Version
  1. 365
Platform
  1. Windows
So I'm having a formula which is TextJoining headers and outputting them in one cell, but based on the data I might end up with duplicates.

The formula which I have now it's looking In for example cell A1 if there is "Code1" then it's looking under cell A2 in another sheet and there is "Code1" it's outputting the header of that second sheet which is located in A1, but the real problem is when you have "Code1" in A3 as well then you see the header twice. I have tried with unique or match, but no luck.

This is example of my formula - =IF(AND(E2<>"",COUNTA(Sheet2!$D$1:$BS$1)=COLUMNS(Sheet2!D1:BS1)),TEXTJOIN(",",,IF(E2=Sheet2!$D$2:$BS$428,Sheet2!$D$1:$BS$1,"")),"")

Thanks in advance.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Could you post a sample of your sheet using XL2BB and your expect result(s)?
 
Upvote 0
Hello @kweaver here is the XL2BB really simple table, but represent the issue, on my case the codes which I'm looking are located in Sheet2, but that can be adjusted in the formula.

This is the formula which I'm using in G5 to collect the result which I'm getting now - =IF(AND(E2<>"",COUNTA(A1:C1)=COLUMNS(A1:C1)),TEXTJOIN(" / ",,IF(E2=A2:C4,A1:C1,"")),"")
I'm looking to adjust this so the result looks more like cell G2.

Book1
ABCDEFG
1Header1Header2Header3Codes to checkExpected result
2Code1Code2Code1Code1Header1 / Header2 / Header3
3Code3Code1Code2Code2
4Code1Code3Result which I'm having now
5Header1 / Header2 / Header3 / Header 1
6
7
8I'm getting double the Header1 from the textjoin because I'm having 2 times Code1 in the column A which is under header1, Is there a way to collect only unuqie values by basically count same codes as 1?
Sheet1
 
Upvote 0
Try this

23 06 21.xlsm
ABCDEFG
1Header1Header2Header3Codes to checkExpected result
2Code1Code2Code1Code1Header1 / Header2 / Header3
3Code3Code1Code2Code2
4Code1Code3
Unique Headers
Cell Formulas
RangeFormula
G2G2=LET(h,TOCOL(IF(ISNUMBER(MATCH(A2:C4,E:E,0)),A1:C1,"")),TEXTJOIN(" / ",,UNIQUE(FILTER(h,h<>""))))
 
Upvote 0
Thanks @Peter_SSs I think it's working, but how I collect the next row in G3 it should be printing Header2 / Header3 since we have Code2 only in these headers.
 
Upvote 0
but how I collect the next row in G3 it should be printing Header2 / Header3 since we have Code2 only in these headers.
I completely misinterpreted your requirement because your original post showed only one "expected result". :oops:
Try this instead

23 06 21.xlsm
ABCDEFG
1Header1Header2Header3Codes to checkExpected result
2Code1Code2Code1Code1Header1 / Header3 / Header2
3Code3Code1Code2Code2Header2 / Header3
4Code1Code3Header1
Unique Headers (2)
Cell Formulas
RangeFormula
G2:G4G2=LET(h,TOCOL(IF(A$2:C$4=E2,A$1:C$1,"")),TEXTJOIN(" / ",,UNIQUE(FILTER(h,h<>""))))
 
Upvote 1
Solution
This should have been all in the one thread, there was no need for two.
 
Upvote 0
I completely misinterpreted your requirement because your original post showed only one "expected result". :oops:
Try this instead

23 06 21.xlsm
ABCDEFG
1Header1Header2Header3Codes to checkExpected result
2Code1Code2Code1Code1Header1 / Header3 / Header2
3Code3Code1Code2Code2Header2 / Header3
4Code1Code3Header1
Unique Headers (2)
Cell Formulas
RangeFormula
G2:G4G2=LET(h,TOCOL(IF(A$2:C$4=E2,A$1:C$1,"")),TEXTJOIN(" / ",,UNIQUE(FILTER(h,h<>""))))
Thank you it's working as intended!
 
Upvote 0
Yes I think the previous thread was quite old that's why I have created a new one.
That is fair enough, but you should not have started a new one and revived the old one so that there were two threads with basically the same question as per #12 of the Forum Rules

Thank you it's working as intended!
You are welcome. Thanks for the confirmation.
 
Upvote 1

Forum statistics

Threads
1,215,201
Messages
6,123,617
Members
449,109
Latest member
Sebas8956

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