CONCATENATE comma question

wonderd

Board Regular
Joined
Oct 20, 2013
Messages
168
Hello I am using this formaula
Code:
=CONCATENATE(IF(COUNT(SEARCH({"phrase 1","phrase 2"},H2)),"40",""))&IF(COUNT(SEARCH({"phrase 3","phrase 4"},H2)),"50","")

Is there a way for me to separate the output by a comma without using a ",50"

If the only output is phrase 3 or phrase 4 then ,50 will cause a problem. I am looking for if both output then 40,50 and if only the second one then 50
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
you could try:
Code:
=CONCATENATE(IF(COUNT(SEARCH({"phrase 1","phrase 2"},H2)),"40",""))&IF(COUNT(SEARCH({"phrase 3","phrase 4"},H2)),",","50","")
Not sure if that is what you're after, but it tested ok at this end
 
Upvote 0
=SUBSTITUTE(TRIM(IF(COUNT(SEARCH({"phrase 1","phrase 2"},H2)),"40","")&" "&IF(COUNT(SEARCH({"phrase 3","phrase 4"},H2)),"50",""))," ",",")
 
Upvote 0
Martins formula works but how would it look if I wanted to add multiple search phrases?
Code:
=CONCATENATE(IF(COUNT(SEARCH({"blue","black"},H2)),",4",""))&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")&IF(COUNT(SEARCH({"purple","green"},H2)),",4","")

Like this but with different phrases and outputs?
 
Upvote 0
I will end up using the above formula then running
Code:
= MID(I2, (LEFT(I2)=",") + 1, LEN(I2))

Thanks for the help, the thread wasn't a total loss....I wouldn't of came up with the above without the help found here and the other thread....
 
Upvote 0
If anyones wondering this is the finished formula
Code:
=CONCATENATE(IF(COUNT(SEARCH("modern",H2)),"modern","")&IF(COUNT(SEARCH("contemporary",H2)),",contemporary","")&IF(COUNT(SEARCH({"oriental","traditional"},H2)),",oriental","")&IF(COUNT(SEARCH({"shag","flokati"},H2)),",shag","")&IF(COUNT(SEARCH("braided",H2)),",braided","")&IF(COUNT(SEARCH("outdoor",H2)),",outdoor","")&IF(COUNT(SEARCH("kid",H2)),",kids","")&IF(COUNT(SEARCH("natural",H2)),",natural","")&IF(COUNT(SEARCH("southwest",H2)),",southwest","")&IF(COUNT(SEARCH({"solid","striped"},H2)),",solid striped","")&IF(COUNT(SEARCH("floral",H2)),",floral","")&IF(COUNT(SEARCH("animal",H2)),",animal","")&IF(COUNT(SEARCH("transitional",H2)),",transitional",""))

Its used for converting attributes of an area rug manufactures excel database to attributes accepted by the website so the products get categorized correctly when uploaded.

I will be creating different versions of this formula for different attributes (weave, color, material)
 
Last edited:
Upvote 0
I still think a UDF or code would have been a far better solution !!
 
Upvote 0
You could be right. How does that work? Is it inserted into the cell like a formula or does it have to be ran like a macro?
 
Upvote 0
No, it's a type of macro......but anyone writing it would have to have ALL the details, and necessary criteria, not dummy data !!
 
Upvote 0

Forum statistics

Threads
1,216,060
Messages
6,128,549
Members
449,458
Latest member
gillmit

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