Horizontal merge into new cell

Westbury

Board Regular
Joined
Jun 7, 2009
Messages
139
How do I use vba to merge the contents of 3 columns on one row into a new cell on that row with each former cell separated with a comma and the last entry in quotation marks?

e.g.

AA BB CC would merge to AA,BB,"CC" in a new cell and the process repeats for n rows

I've found lots of ideas to create a single column from data but not to execute a horizontal merge.

Thanks
 
Last edited:
Fluff, thank you for your last post. Yes, your assumption was correct, this is the solution to my needs.
Many thanks,
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You're welcome & thanks for the feedback
 
Upvote 0
Fluff, I've tested your code and it works fine on variousvamounts of data but when I use it in on 15500 rows, Excel goes into melt down. No VBA error message, but the words "not responding" appear on the excel titlebar. Is this a virtual memory issue or something else?
 
Upvote 0
With that amount of data it's going to be slow, try this instead
Code:
Sub Westbury()
   Dim Ary As Variant, Nary As Variant
   Dim i As Long
   
   With Sheets("Sheet1")
      Ary = .Range("A1", .Range("A" & Rows.count).End(xlUp).Offset(, 3)).Value2
   End With
   ReDim Nary(1 To UBound(Ary), 1 To 2)
   For i = 1 To UBound(Ary)
      Nary(i, 1) = Ary(i, 1) & "," & Ary(i, 2) & ",""" & Ary(i, 3) & """"
   Next i
   Sheets("Sheet2").Range("A1").Resize(i - 1, 2).Value = Nary
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,847
Messages
6,121,911
Members
449,054
Latest member
luca142

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