Can I use function if and concatenate together?

mpatino

Board Regular
Joined
Jul 8, 2009
Messages
82
Hi guys,

can anyone tell me ow can I use an if statement together with concatenate? I have 2 columns A with products and B with key words, so for example I need to look in column A "Shampoo" (may be just in one cell or several) and then if "Shampoo" is found in several cells, I need to concatenate all the key words from column B.

A B
1 Shampoo Hair
2 Lotion White
3 Shampoo Soft
4 Shampoo Fresh

Result: Hair, Soft, Fresh
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Excel 2007
ABCDEFGH
location of space charlen of stringfirst wordsecond word
Shampoo HairShampooHairHair,
Lotion WhiteLotionWhite
Shampoo SoftShampooSoftSoft,
Shampoo FreshShampooFreshFresh,
Hair,Soft,Fresh,Hair,Soft,Fresh

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

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

[TD="align: center"]2[/TD]
[TD="align: right"]1[/TD]

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

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

[TD="align: center"]3[/TD]
[TD="align: right"]2[/TD]

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

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

[TD="align: center"]4[/TD]
[TD="align: right"]3[/TD]

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

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

[TD="align: center"]5[/TD]
[TD="align: right"]4[/TD]

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

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

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

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #E0E0F0"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C2[/TH]
[TD="align: left"]=FIND(" ",B2,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D2[/TH]
[TD="align: left"]=LEN(B2)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E2[/TH]
[TD="align: left"]=LEFT(B2,C2-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F2[/TH]
[TD="align: left"]=RIGHT(B2,D2-C2)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G2[/TH]
[TD="align: left"]=IF(E2="Shampoo",F2&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C3[/TH]
[TD="align: left"]=FIND(" ",B3,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D3[/TH]
[TD="align: left"]=LEN(B3)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E3[/TH]
[TD="align: left"]=LEFT(B3,C3-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F3[/TH]
[TD="align: left"]=RIGHT(B3,D3-C3)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G3[/TH]
[TD="align: left"]=IF(E3="Shampoo",F3&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C4[/TH]
[TD="align: left"]=FIND(" ",B4,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D4[/TH]
[TD="align: left"]=LEN(B4)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E4[/TH]
[TD="align: left"]=LEFT(B4,C4-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F4[/TH]
[TD="align: left"]=RIGHT(B4,D4-C4)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G4[/TH]
[TD="align: left"]=IF(E4="Shampoo",F4&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C5[/TH]
[TD="align: left"]=FIND(" ",B5,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D5[/TH]
[TD="align: left"]=LEN(B5)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E5[/TH]
[TD="align: left"]=LEFT(B5,C5-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F5[/TH]
[TD="align: left"]=RIGHT(B5,D5-C5)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G5[/TH]
[TD="align: left"]=IF(E5="Shampoo",F5&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G6[/TH]
[TD="align: left"]=G2&G3&G4&G5[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H6[/TH]
[TD="align: left"]=LEFT(G6,15)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi Mark,

thanks for your reply, my table actually looks like this:

[TABLE="width: 568"]
<tbody>[TR]
[TD][/TD]
[TD] A

[/TD]
[TD] B

[/TD]
[TD]
[/TD]
[TD] D

[/TD]
[TD] E

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="colspan: 2"] This is what I have

[/TD]
[TD][/TD]
[TD="colspan: 2"]The Results should look like this

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Products


[/TD]
[TD="align: left"]Description


[/TD]
[TD][/TD]
[TD]Product

[/TD]
[TD]Descritions

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Shampoo

[/TD]
[TD="align: left"]hair

[/TD]
[TD][/TD]
[TD="align: left"]Shampoo

[/TD]
[TD="align: left"]hair, soft, fresh

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Lotion

[/TD]
[TD="align: left"]white

[/TD]
[TD][/TD]
[TD="align: left"]Lotion

[/TD]
[TD="align: left"]white, green

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Shampoo

[/TD]
[TD="align: left"]soft

[/TD]
[TD][/TD]
[TD="align: left"]Conditioner

[/TD]
[TD="align: left"]important, soft

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Conditioner

[/TD]
[TD="align: left"]important

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Lotion

[/TD]
[TD="align: left"]green

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Conditioner

[/TD]
[TD="align: left"]Soft

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Shampoo

[/TD]
[TD="align: left"]fresh

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi

Have a look at:
http://www.mrexcel.com/forum/excel-questions/365691-concatenate-multiple-cells-array-formula.html

Also, please look at below, but it's not ideal:

Excel 2007
ABCDEFGHI
location of space charlen of stringfirst wordsecond wordShampooLotionConditioner
Shampoo HairShampooHairHair,
Lotion WhiteLotionWhiteWhite,
Shampoo SoftShampooSoftSoft,
Shampoo FreshShampooFreshFresh,
Conditioner ImportantConditionerImportantImportant,
Conditioner SoftConditionerSoftSoft,
Lotion GreenLotionGreenGreen,
Hair,Soft,Fresh,White,Green,Important,Soft,
ResultsDescriptions
ShampooHair,Soft,Fresh,
LotionWhite,Green,
ConditionerImportant,Soft,

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

[TD="align: center"]2[/TD]
[TD="align: right"]1[/TD]

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

[TD="align: center"]3[/TD]
[TD="align: right"]2[/TD]

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

[TD="align: center"]4[/TD]
[TD="align: right"]3[/TD]

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

[TD="align: center"]5[/TD]
[TD="align: right"]4[/TD]

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

[TD="align: center"]6[/TD]
[TD="align: right"]5[/TD]

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

[TD="align: center"]7[/TD]
[TD="align: right"]6[/TD]

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

[TD="align: center"]8[/TD]
[TD="align: right"]7[/TD]

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

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

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

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

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

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

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

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

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

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

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

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

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #E0E0F0"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C2[/TH]
[TD="align: left"]=FIND(" ",B2,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D2[/TH]
[TD="align: left"]=LEN(B2)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E2[/TH]
[TD="align: left"]=LEFT(B2,C2-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F2[/TH]
[TD="align: left"]=RIGHT(B2,D2-C2)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G2[/TH]
[TD="align: left"]=IF(E2="Shampoo",F2&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H2[/TH]
[TD="align: left"]=IF(E2="Lotion",F2&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I2[/TH]
[TD="align: left"]=IF(E2="Conditioner",F2&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C3[/TH]
[TD="align: left"]=FIND(" ",B3,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D3[/TH]
[TD="align: left"]=LEN(B3)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E3[/TH]
[TD="align: left"]=LEFT(B3,C3-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F3[/TH]
[TD="align: left"]=RIGHT(B3,D3-C3)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G3[/TH]
[TD="align: left"]=IF(E3="Shampoo",F3&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H3[/TH]
[TD="align: left"]=IF(E3="Lotion",F3&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I3[/TH]
[TD="align: left"]=IF(E3="Conditioner",F3&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C4[/TH]
[TD="align: left"]=FIND(" ",B4,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D4[/TH]
[TD="align: left"]=LEN(B4)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E4[/TH]
[TD="align: left"]=LEFT(B4,C4-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F4[/TH]
[TD="align: left"]=RIGHT(B4,D4-C4)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G4[/TH]
[TD="align: left"]=IF(E4="Shampoo",F4&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H4[/TH]
[TD="align: left"]=IF(E4="Lotion",F4&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I4[/TH]
[TD="align: left"]=IF(E4="Conditioner",F4&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C5[/TH]
[TD="align: left"]=FIND(" ",B5,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D5[/TH]
[TD="align: left"]=LEN(B5)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E5[/TH]
[TD="align: left"]=LEFT(B5,C5-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F5[/TH]
[TD="align: left"]=RIGHT(B5,D5-C5)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G5[/TH]
[TD="align: left"]=IF(E5="Shampoo",F5&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H5[/TH]
[TD="align: left"]=IF(E5="Lotion",F5&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I5[/TH]
[TD="align: left"]=IF(E5="Conditioner",F5&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C6[/TH]
[TD="align: left"]=FIND(" ",B6,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D6[/TH]
[TD="align: left"]=LEN(B6)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E6[/TH]
[TD="align: left"]=LEFT(B6,C6-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F6[/TH]
[TD="align: left"]=RIGHT(B6,D6-C6)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G6[/TH]
[TD="align: left"]=IF(E6="Shampoo",F6&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H6[/TH]
[TD="align: left"]=IF(E6="Lotion",F6&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I6[/TH]
[TD="align: left"]=IF(E6="Conditioner",F6&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C7[/TH]
[TD="align: left"]=FIND(" ",B7,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D7[/TH]
[TD="align: left"]=LEN(B7)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E7[/TH]
[TD="align: left"]=LEFT(B7,C7-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F7[/TH]
[TD="align: left"]=RIGHT(B7,D7-C7)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G7[/TH]
[TD="align: left"]=IF(E7="Shampoo",F7&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H7[/TH]
[TD="align: left"]=IF(E7="Lotion",F7&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I7[/TH]
[TD="align: left"]=IF(E7="Conditioner",F7&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]C8[/TH]
[TD="align: left"]=FIND(" ",B8,1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]D8[/TH]
[TD="align: left"]=LEN(B8)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]E8[/TH]
[TD="align: left"]=LEFT(B8,C8-1)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]F8[/TH]
[TD="align: left"]=RIGHT(B8,D8-C8)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G8[/TH]
[TD="align: left"]=IF(E8="Shampoo",F8&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H8[/TH]
[TD="align: left"]=IF(E8="Lotion",F8&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I8[/TH]
[TD="align: left"]=IF(E8="Conditioner",F8&",","")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]G9[/TH]
[TD="align: left"]=G2&G3&G4&G5&G6&G7&G8[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H9[/TH]
[TD="align: left"]=H2&H3&H4&H5&H6&H7&H8[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]I9[/TH]
[TD="align: left"]=I2&I3&I4&I5&I6&I7&I8[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H13[/TH]
[TD="align: left"]=G9[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H14[/TH]
[TD="align: left"]=H9[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #E0E0F0"]H15[/TH]
[TD="align: left"]=I9[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi Mark,

thanks for your reply, my table actually looks like this:

[TABLE="width: 568"]
<tbody>[TR]
[TD][/TD]
[TD] A

[/TD]
[TD] B

[/TD]
[TD]
[/TD]
[TD] D

[/TD]
[TD] E

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="colspan: 2"] This is what I have

[/TD]
[TD][/TD]
[TD="colspan: 2"]The Results should look like this

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Products

[/TD]
[TD="align: left"]Description
[/TD]
[TD][/TD]
[TD]Product

[/TD]
[TD]Descritions

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Shampoo

[/TD]
[TD="align: left"]hair

[/TD]
[TD][/TD]
[TD="align: left"]Shampoo

[/TD]
[TD="align: left"]hair, soft, fresh

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Lotion

[/TD]
[TD="align: left"]white

[/TD]
[TD][/TD]
[TD="align: left"]Lotion

[/TD]
[TD="align: left"]white, green

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Shampoo

[/TD]
[TD="align: left"]soft

[/TD]
[TD][/TD]
[TD="align: left"]Conditioner

[/TD]
[TD="align: left"]important, soft

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Conditioner

[/TD]
[TD="align: left"]important

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Lotion

[/TD]
[TD="align: left"]green

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Conditioner

[/TD]
[TD="align: left"]Soft

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"] Shampoo

[/TD]
[TD="align: left"]fresh

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Let A:B house the first table and D:E the second table.

Add the following code in <acronym title="visual basic for applications">VBA</acronym> to your workbook using Alt+F11...

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function

Now invoke...

E2, control+shift+enter and copy down:

=REPLACE(aconcat(IF($A$3:$A$7=$D3,", "&$B$3:$B$7,"")),1,2,"")
 
Upvote 0
Hi Mark,

thanks for your reply, my table actually looks like this:

[TABLE="width: 568"]
<TBODY>[TR]
[TD][/TD]
[TD]
A

[/TD]
[TD]
B

[/TD]
[TD]
[/TD]
[TD]
D

[/TD]
[TD]
E

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="colspan: 2"]
This is what I have

[/TD]
[TD][/TD]
[TD="colspan: 2"]
The Results should look like this

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Products

[/TD]
[TD="align: left"]
Description

[/TD]
[TD][/TD]
[TD]
Product

[/TD]
[TD]
Descritions

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Shampoo

[/TD]
[TD="align: left"]
hair

[/TD]
[TD][/TD]
[TD="align: left"]
Shampoo

[/TD]
[TD="align: left"]
hair, soft, fresh

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Lotion

[/TD]
[TD="align: left"]
white

[/TD]
[TD][/TD]
[TD="align: left"]
Lotion

[/TD]
[TD="align: left"]
white, green

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Shampoo

[/TD]
[TD="align: left"]
soft

[/TD]
[TD][/TD]
[TD="align: left"]
Conditioner

[/TD]
[TD="align: left"]
important, soft

[/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Conditioner

[/TD]
[TD="align: left"]
important

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Lotion

[/TD]
[TD="align: left"]
green

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Conditioner

[/TD]
[TD="align: left"]
Soft

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"][/TD]
[TD="align: left"]
Shampoo

[/TD]
[TD="align: left"]
fresh

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</TBODY>[/TABLE]
I posted a UDF (user defined function) in the following mini-blog article which will do exactly what you are asking for (and more)...

LookUp Value and Concatenate All Found Results
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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