Concatenate 3 columns without spaces

trivera648

New Member
Joined
Jan 29, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I would like to concatenate three columns onto a fourth column. However I don't want any spaces contained within the data concatenated on the fourth column.

I found this macro from Rick Rothstein posted on another thread, it's perfect. Except I can't figure out how to edit the code to exclude spaces between each value retrieved.

VBA Code:
Code:     
   
       Sub ConcatColumnsABC()
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("D1:D" & LastRow) = Evaluate(Replace("A1:A#&"" ""&B1:B#&"" ""&C1:C#", "#", LastRow))
End Sub



Any help would be most appreciated.


Thank you!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
How About:
VBA Code:
Sub ConcatColumnsABC()
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("D1:D" & LastRow) = Evaluate(Replace("A1:A#&B1:B#&C1:C#", "#", LastRow))
End Sub
 
Upvote 0
Solution
How About:
VBA Code:
Sub ConcatColumnsABC()
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("D1:D" & LastRow) = Evaluate(Replace("A1:A#&B1:B#&C1:C#", "#", LastRow))
End Sub
This works! Thank you maabadi!!
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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