Concatenate unique text values in Excel 2016 (based on criteria in range)

art_TD

New Member
Joined
Sep 19, 2024
Messages
10
Office Version
  1. 2016
Hi! Could you please help with such issue?
I am trying to concatenate unique (exact) text values within a range (Name) based on a criteria in another range (Code). No VBA please, just formula(s).

CodeNameConcat
12345​
RollerRollerRoller; idler; sprocket;
12345​
Rolleridler; sprocket;
12345​
Rolleridler; sprocket;
12345​
Rolleridler; sprocket;
12345​
Rolleridler; sprocket;
12345​
Rolleridler; sprocket;
12345​
Rolleridler; sprocket;
12345​
IdlerIdlerIdler; sprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
Idlersprocket;
12345​
SprocketSprocketSprocket;
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
54321
RollerRollerRoller; ???; ???
54321
Idler
54321
Sprocket
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Like this?
Cell D2 when first two columns start at A1:
Excel Formula:
=TEXTJOIN("; ",,UNIQUE(CHOOSECOLS(FILTER($A$2:$B$31, $A$2:$A$31=A2),2)))
 
Upvote 0
Hi & Welcome to Mr. Excel.

Try

Book1
ABCD
1CodeNameConcatFormula
212345RollerRollerRoller; Idler; Sprocket;
312345Roller Idler; Sprocket;
412345Roller Idler; Sprocket;
512345Roller Idler; Sprocket;
612345Roller Idler; Sprocket;
712345Roller Idler; Sprocket;
812345Roller Idler; Sprocket;
912345IdlerIdlerIdler; Sprocket;
1012345Idler Sprocket;
1112345Idler Sprocket;
1212345Idler Sprocket;
1312345Idler Sprocket;
1412345Idler Sprocket;
1512345Idler Sprocket;
1612345Idler Sprocket;
1712345Idler Sprocket;
1812345Idler Sprocket;
1912345SprocketSprocketSprocket;
2012345Sprocket  
2112345Sprocket  
2212345Sprocket  
2312345Sprocket  
2412345Sprocket  
2512345Sprocket  
2612345Sprocket  
2712345Sprocket  
2812345Sprocket  
2954321RollerRollerRoller; Idler; Sprocket
3054321IdlerIdlerIdler; Sprocket
3154321SprocketSprocketSprocket
32
Sheet1
Cell Formulas
RangeFormula
C2:C31C2=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,B2,"")
D2:D31D2=IF(A3="",C2,IF(A2<>A3,"",IF(C2="",D3,C2&"; "&D3)))
 
Upvote 0
Solution
Hi Sufiyan97,

It is what I needed. Great and thanks for your help!

Just curious why the 1st group has a semicolon at the end of concatenated texts while the 2nd doesn't. (I actually has a solution with a helper column to remove ";")
 
Upvote 0
And one more question - if the order of codes is random (codes are mixed within this range), would it be possible to keep looking for unique values and retrieve them if available?

CodeName
12345​
RollerRollerRoller; Idler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
IdlerIdlerIdler; Sprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
SprocketSprocketSprocket;
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
54321​
RollerRollerRoller; Idler;
54321​
IdlerIdlerIdler;
54321​
SprocketSprocket
12345
Track ShoeTrack ShoeTrack Shoe
 
Upvote 0
Hi Sufiyan97,

It is what I needed. Great and thanks for your help!

Just curious why the 1st group has a semicolon at the end of concatenated texts while the 2nd doesn't. (I actually has a solution with a helper column to remove ";")


I have modified formula and added a column E for without semicolon

Book1
ABCDEF
1CodeNameConcatFormula with semicolonFormula without semicolon
212345RollerRollerRoller; Idler; Sprocket; Roller; Idler; Sprocket
312345Roller Idler; Sprocket; Idler; Sprocket
412345Roller Idler; Sprocket; Idler; Sprocket
512345Roller Idler; Sprocket; Idler; Sprocket
612345Roller Idler; Sprocket; Idler; Sprocket
712345Roller Idler; Sprocket; Idler; Sprocket
812345Roller Idler; Sprocket; Idler; Sprocket
912345IdlerIdlerIdler; Sprocket; Idler; Sprocket
1012345Idler Sprocket; Sprocket
1112345Idler Sprocket; Sprocket
1212345Idler Sprocket; Sprocket
1312345Idler Sprocket; Sprocket
1412345Idler Sprocket; Sprocket
1512345Idler Sprocket; Sprocket
1612345Idler Sprocket; Sprocket
1712345Idler Sprocket; Sprocket
1812345Idler Sprocket; Sprocket
1912345SprocketSprocketSprocket; Sprocket
2012345Sprocket   
2112345Sprocket   
2212345Sprocket   
2312345Sprocket   
2412345Sprocket   
2512345Sprocket   
2612345Sprocket   
2712345Sprocket   
2812345Sprocket   
2954321RollerRollerRoller; Idler; Sprocket;Roller; Idler; Sprocket
3054321IdlerIdlerIdler; Sprocket;Idler; Sprocket
3154321SprocketSprocketSprocket;Sprocket
32
Sheet1
Cell Formulas
RangeFormula
C2:C31C2=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,B2,"")
D2:D31D2=IF(A3="",C2&";",IF(A2<>A3,"",IF(C2="",D3,C2&"; "&D3)))
E2:E31E2=IF(A3="",C2,IF(A2<>A3,"",IF(C2="",E3,C2&IF(E3="","","; ")&E3)))
 
Upvote 0
And one more question - if the order of codes is random (codes are mixed within this range), would it be possible to keep looking for unique values and retrieve them if available?

CodeName
12345​
RollerRollerRoller; Idler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
RollerIdler; Sprocket;
12345​
IdlerIdlerIdler; Sprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
IdlerSprocket;
12345​
SprocketSprocketSprocket;
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
12345​
Sprocket
54321​
RollerRollerRoller; Idler;
54321​
IdlerIdlerIdler;
54321​
SprocketSprocket
12345
Track ShoeTrack ShoeTrack Shoe

Can you post some manually typed expected results?
 
Upvote 0
It should be like this after all.

1726836390663.png
 

Attachments

  • 1726836294745.png
    1726836294745.png
    13.5 KB · Views: 123
  • 1726836356912.png
    1726836356912.png
    11.9 KB · Views: 122
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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