Oh, ye of little endurance! Hundreds of messages have been written on
this topic in many different programming language ngs.
If the delimiting char could appear in a field, then an alternative
would be delimiting the field, say, with double quotes. At that point
it becomes expedient to process each field before concatenating it to
the others. As in this monster.
=SUBSTITUTE(SUBSTITUTE(TRIM(
SUBSTITUTE(IF(COUNTIF(A1,"*,*")-COUNTIF(A1,"""*"""),
""""&A1&"""",A1)," ",CHAR(127))&" "&
SUBSTITUTE(IF(COUNTIF(B1,"*,*")-COUNTIF(B1,"""*"""),
""""&B1&"""",B1)," ",CHAR(127))&" "&
SUBSTITUTE(IF(COUNTIF(C1,"*,*")-COUNTIF(C1,"""*"""),
""""&C1&"""",C1)," ",CHAR(127))&" "&
SUBSTITUTE(IF(COUNTIF(D1,"*,*")-COUNTIF(D1,"""*"""),
""""&D1&"""",D1)," ",CHAR(127))&" "&
SUBSTITUTE(IF(COUNTIF(E1,"*,*")-COUNTIF(E1,"""*"""),
""""&E1&"""",E1)," ",CHAR(127)))," ",", "),CHAR(127)," ")
Two things about your formula. One, you stopped one column too soon... the
OP wanted it carried out to Column F. Not a big deal as the extension is
easy enough to do. Two, why are you subtracting off COUNTIF(C1,"""*""") in
your IF conditional tests? I mean, I think I know what you were trying to do
(stop some kind of recursion); but, on a hunch, I removed them all and your
formula worked fine without them. The only other thing you could have done
to shorten you formula is to use CHAR(1) instead of CHAR(127) which saves 14
(assuming you extend your formula for Column F. Here is your formula
reworked for the above comments...
=SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(IF(COUNTIF(A1,"*,*"),""""&A1&"""",A1),"
",CHAR(1))&" "&SUBSTITUTE(IF(COUNTIF(B1,"*,*"),""""&B1&"""",B1),"
",CHAR(1))&" "&SUBSTITUTE(IF(COUNTIF(C1,"*,*"),""""&C1&"""",C1),"
",CHAR(1))&" "&SUBSTITUTE(IF(COUNTIF(D1,"*,*"),""""&D1&"""",D1),"
",CHAR(1))&" "&SUBSTITUTE(IF(COUNTIF(E1,"*,*"),""""&E1&"""",E1),"
",CHAR(1))&" "&SUBSTITUTE(IF(COUNTIF(F1,"*,*"),""""&F1&"""",F1),"
",CHAR(1)))," ",", "),CHAR(1)," ")
As far as I can tell, it seems to work fine.
Rick