vba concatenate with space

excel01noob

Board Regular
Joined
Aug 5, 2019
Messages
93
Office Version
  1. 365
  2. 2016
I have a sheet with data in several columns.
I want to use column A data (month) with colum D data (Product) and column E (billing ID)

How do I concatenate these 3 columns and have the data separated by space?
something like this

March pencil B34009
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You didn't provide a lot of information about your data or code, so I don't know if this is the solution you came up with or not. Here is a non-looping solution for you (outputs to Column H) assuming your data starts in Row 2...
VBA Code:
Sub Test()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Range("H2:H" & LastRow) = Evaluate(Replace("A2:A#&"" ""&D2:D#&"" ""&E2:E#", "#", LastRow))
End Sub
 
Upvote 0
how would I make it work the concat if I want to add into column P (assuming header):

-letter C and
-account number (it's a 8 digits number) from column H until last row with data

C12345678
 
Upvote 0
Are you wanting this added to the macro I gave you earlier or is this supposed to be a separate macro?
 
Upvote 0
-letter C and
-account number (it's a 8 digits number) from column H until last row with data

It will be part of the same macro
Wait a minute!!! I just noticed that my previous code outputs to Column H and what it outputs is not an 8-digit number?!!??!? Please explain.
 
Upvote 0
the output in the first macro was not in column H, I have amended the code to the correct column (it is column O)
 
Upvote 0
Give this a try...
VBA Code:
Sub Test()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Range("O2:O" & LastRow) = Evaluate(Replace("A2:A#&"" ""&D2:D#&"" ""&E2:E#", "#", LastRow))
  Range("P2:P" & LastRow) = Evaluate("TEXT(H2:H" & LastRow & ",""C00000000"")")
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,457
Messages
6,124,941
Members
449,197
Latest member
k_bs

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