View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Multiple returned values into a single cell

Some comments: The space after the comma could be included in the
formula.


The OP doesn't show a space after his commas in the original postings sample
output, so I didn't include any either.

If there are no Yes conditions, it returns an error.


The following formula should take care of that...

=SUBSTITUTE(IF(B2="Yes",B1&",","")&IF(C2="Yes",C1& ",","")&IF(D2="Yes",D1&",","")&IF(E2="Yes",E1&",", ""),",","",(COUNTIF(B2:E2,"=Yes")=0)+COUNTIF(B2:E2 ,"=Yes"))

It'll get confounded if the city has a comma in it.


Yes, that is true... but then a comma would be a poor choice of delimiter
for a list of cities that could contain commas of their own. HOWEVER, not
being one to shrink away from a challenge<g, this formula will produce a
comma delimited list where the items being delineated could possibly contain
commas of their own...

=SUBSTITUTE(SUBSTITUTE(IF(B2="Yes",B1&"$","")&IF(C 2="Yes",C1&"$","")&IF(D2="Yes",D1&"$","")&IF(E2="Y es",E1&"$",""),"$","",(COUNTIF(B2:E2,"=Yes")=0)+CO UNTIF(B2:E2,"=Yes")),"$",",")

Rick