Combine Many Cells Into One Cell

L

Legacy 436357

Guest
Hello,

I have test equipment numbers in separate columns. How can I combine them into one column with the numbers separated by commas and one space after each comma?

Note some columns don't have numbers.

Thank you

Excel Workbook
EFGHIJ
112663
11313721240355105
11466314221408
11511801417
11692213651424
117663
1181379138014151373883884
119663801
120
1211217121812401365
1226638011415
123
12455610181418
12555610181418
1265561418
1271202697
12864214491415
Sheet1
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hey, you can use a function called TEXTJOIN with the delimiter as ", "

=TEXTJOIN(", ",TRUE,E112:E128) for example.
 
Upvote 0
What version of Xl are you running?
 
Upvote 0
try
Code:
Set MyRange = Application.Selection
For Each c In MyRange
     cTot = cTot + ", " + CStr(c.Value)
    c.Value = ""
Next c
MyRange.Cells(1, 1) = Mid(cTot, 2, 1000)
 
Last edited:
Upvote 0
A few samples like this. Is it possible?

Excel Workbook
L
1151180, 1417
116922, 1365, 1424
117663
1181379, 1380, 1415, 1373, 883, 884
119663, 801
Sheet1
 
Upvote 0
=if(e113>0,e113&", ","")&if(f113>0,f113&", ","")&if(g113>0,g113&", ","")&if(h113>0,h113&", ","")&if(I113>0,I113&", ","")&if(J113>0,J113&", ","")&if(K113>0,K113,"")
 
Last edited:
Upvote 0
How about
Code:
Function xjohnson(Rng As Range) As String
   xjohnson = Replace(Application.Trim(Join(Application.Index(Rng.Value, 1, 0), " ")), " ", ", ")
End Function
Used like
=xjohnson(E2:J2)
 
Upvote 0
Jondavis1987,

This is close but it has an extra comma at the end of the last number.
 
Upvote 0

Forum statistics

Threads
1,224,885
Messages
6,181,583
Members
453,055
Latest member
cope7895

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