How do I concantenate two columns for the length of a table?

Z

zach-18

I have a daily report in which I need to combine the 1st and last name. I
would like to write a macro that would concatenate the report, regardless of
the number of rows. If the 1st name is in Col A, last name is in Col B, and
the combined would go in Col C, what would the VBA text look like?

Thanks and Kind Regards in advance for any help.
 
J

JLGWhiz

Sub PutTogether()
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 to lastRow '<<assumes header row
Range("C" & i) = Cells(i, 1) & " " & Cells(i, 2)
Next
End Sub
 
R

Rick Rothstein \(MVP - VB\)

Assuming your data starts in Row 2, have you considered putting this...

=A2&" "&B2

in C2 and copying it down far enough to cover the maximum possible row you
ever expect to use? That way, the concatenation operation would take
immediately without you have to manually run a macro.

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top