ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I concantenate two columns for the length of a table? (https://www.excelbanter.com/excel-programming/412494-how-do-i-concantenate-two-columns-length-table.html)

zach-18

How do I concantenate two columns for the length of a table?
 
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.

JLGWhiz

How do I concantenate two columns for the length of a table?
 
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

"zach-18" wrote:

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.


Rick Rothstein \(MVP - VB\)[_2099_]

How do I concantenate two columns for the length of a table?
 
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


"zach-18" wrote in message
...
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.



zach-18[_2_]

How do I concantenate two columns for the length of a table?
 
You hit the nail on the head! thanks so much, you saved me hours of time.

"JLGWhiz" wrote:

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

"zach-18" wrote:

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.



All times are GMT +1. The time now is 08:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com