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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If you have a version of Excel with TEXTJOIN, then try this:

ABCDEFGHIJKLMN
1TreatmentNutrition 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>
</tbody>
Sheet1

Array Formulas
CellFormula
L1{=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,""))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



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,215,062
Messages
6,122,923
Members
449,094
Latest member
teemeren

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