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

rette

New Member
Joined
Oct 29, 2015
Messages
4
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>
</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>
</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!
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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)," ",", ")
 

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,761
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)," ",",")
 

rette

New Member
Joined
Oct 29, 2015
Messages
4
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!
 

Forum statistics

Threads
1,082,046
Messages
5,362,873
Members
400,696
Latest member
Kclynn

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top