Find multiple cells that match and if they do concatenate the adjacent cells

bran987

New Member
Joined
Jan 10, 2005
Messages
45
I have a spreadsheet with thousands of lines but I will just show one line because each row is independent.

For the life of me I cannot figure out how to format the example in this message space, so I put a public link to a Google Sheet, but I am using EXCEL for the actual spreadsheet not Google.

If this is not OK can someone point me to directions on how to post data cell examples?

https://docs.google.com/spreadsheets/d/1t8hdGEEkuR8C_hJs-IPY4HcmlNokqKCaE2TJLMpd-TQ/edit?usp=sharing

You can see Treatment is there twice (A1 and G1) so I want to output B1 and H1 into L1 separated by space semicolon space " ; "
Supplement Line is only there once (C1) so I don't need to combine it with anything, I just need D1 to output into M1
Aesthetics is also there twice (E1 and I1) so I want to output F1 and J1 respectively into N1 also separated the same way " ; "

I have 19 different categories that would be in green.

Thanks so much everyone.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you have a version of Excel with TEXTJOIN, then try this:

ABCDEFGHIJKLMN
TreatmentNutrition ProgramSupplement LineB12AestheticsBotoxTreatmentPersonal TrainerAestheticsJuvedermNutrition Program ; Personal TrainerB12Botox ; Juvederm

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]L1[/TH]
[TD="align: left"]{=TEXTJOIN(" ; ",TRUE,IF($A1:$I1=INDEX($A1:$I1,SMALL(IF(MOD(COLUMN($A1:$I1),2)=1,IF(MATCH($A1:$I1,$A1:$I1,0)=COLUMN($A1:$I1),COLUMN($A1:$I1))),COLUMNS($L1:L1))),$B1:$J1,""))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]



This formula works if the ranges are A:J, if you change the ranges or add columns, we'll need to adjust the formula. If you don't have TEXTJOIN, you'll probably need some version of VBA.

To display a formatted screen print like I did, check the HTML Maker link in my signature.
 
Upvote 0
If you have a version of Excel with TEXTJOIN, then try this:

Wow Eric that worked perfectly all across Row 1! Except when I tried to CTRL+C the formula down into the next row it gives #N/A ?
 
Last edited:
Upvote 0
Upon thinking upon it a bit more, you may want to wrap the formula in IFERROR in case you pull the formula over past the number of unique terms. In any case, I'm glad it works for you! :cool:
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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