Combine information from many columns into one but skip if blank and insert commas

rette

New Member
Joined
Oct 29, 2015
Messages
6
Have 6 columns of data (like below but some columns could be blank or even all) and then a column that will summarize the preceding information such as the examples below:

AG1MSC1MG1SR1AA1CY1PG1

<colgroup><col width="87" span="7" style="width:65pt"> </colgroup><tbody>
<!--StartFragment-->
<!--EndFragment-->
</tbody>

next column would show the following:
AG1, MSC1, MG1, SR1, AA1, CY1, PG1

OR like the below if cells are blank,

AG1MG1SR1PG1

<colgroup><col width="87" span="7" style="width: 65pt;"></colgroup><tbody>
</tbody>

next column would show the following:
AG1, MG1, SR1, PG1

<tbody>
<!--EndFragment-->
</tbody>
I need a formula that will summarize, skip blanks and add the commas. Please help - had it figured out but computer crashed in the middle but my export was a csv and I stupidly hadn't converted to an XLS yet and so it flattened the formula and I couldn't restore and now I can't re-create.

Thanks!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try this assuming there will not be any pre existing spaces in any of the original values.

=SUBSTITUTE(TRIM(A1&" "&B1&" "&C1&" "&D1&" "&E1&" "&F1&" "&G1)," ",", ")
 
Upvote 0
The most efficient approach would be to write a UDF but if you want a formula solution, try: =SUBSTITUTE(TRIM(A1&" "&B1&" "&C1&" "&D1&" "&E1&" "&F1&" "&G1)," ",",")
 
Upvote 0
YAY You guys are life savers!!!! Report is due this afternoon and had found the formula on this board and tweaked it to work but couldn't get back there. This is what a couple concussions will do to your memory.

Life long user!
 
Upvote 0

Forum statistics

Threads
1,214,859
Messages
6,121,963
Members
449,059
Latest member
oculus

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