'Code' or 'Function' to concatenate into single cell ?

Maverick27

Active Member
Joined
Sep 23, 2010
Messages
336
Office Version
  1. 2013
Platform
  1. Windows
Hi - anyone care to share a piece of code (or function) to "concatenate" the data in cell cols. from A to L into a single cell M that should read as below. It should also have commas, inverted commas & brackets.

('01','OSR00001','25W B22 GLS LAMP FROSTED','OSGL25B22','735','1617','Frosted','Pin','B22','-','-','25')

Worksheet sample link:
http://imageshack.us/photo/my-images/69/excelnz.jpg/

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try

Code:
Function Concat(r As Range) As String
Dim c As Range
Concat = "("
For Each c In r
    Concat = Concat & "'" & c.Value & "'" & ","
Next c
Concat = Left(Concat, Len(Concat) - 1)
Concat = Concat & ")"
End Function

Use like

=concat(A1:L1)
 
Upvote 0
That is the exact code. Press ALT + F11 to open the Visual Basic Editor, select Module from the Insert menu then paste in the code. Press ALT + Q to close the code window.

On the worksheet enter a formula like

=concat(A1:L1)
 
Upvote 0
What i'm simply saying is that when i place cursor in a cell of COL M , i see the formula.
But, i want to see the TEXT itself.
 
Upvote 0
Select the values in column M and copy them. Edit > Paste Special, tick Values and click OK.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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