ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need to combine first and last name from two columns (https://www.excelbanter.com/excel-programming/287495-need-combine-first-last-name-two-columns.html)

Dave[_38_]

Need to combine first and last name from two columns
 
This is what I have. I need some help as indicated in the comments:

Sub Combine()

Do ' Outer loop.

ActiveCell.Select
last = ActiveCell.Formula

'need to move one cell to the right here

ActiveCell.Select
first = ActiveCell.Formula

'need to move one cell to the right here

ActiveCell.FormulaR1C1 = last + ", " + first

' need to move back to column one here

' need to move down one row here

Loop Until EOF 'Will this stop at the first empty value in column one?

End Sub


Thank you in advance.



Rob van Gelder[_4_]

Need to combine first and last name from two columns
 
Dave,

Sub testit()
Dim i As Long, lngLastRow As Long

With Sheet1
lngLastRow = .Cells(1, 1).End(xlDown).Row
For i = 1 To lngLastRow
.Cells(i, 3) = .Cells(i, 1) & ", " & .Cells(i, 2)
Next
End With
End Sub


Rob

"Dave" wrote in message
...
This is what I have. I need some help as indicated in the comments:

Sub Combine()

Do ' Outer loop.

ActiveCell.Select
last = ActiveCell.Formula

'need to move one cell to the right here

ActiveCell.Select
first = ActiveCell.Formula

'need to move one cell to the right here

ActiveCell.FormulaR1C1 = last + ", " + first

' need to move back to column one here

' need to move down one row here

Loop Until EOF 'Will this stop at the first empty value in column one?

End Sub


Thank you in advance.





Dave[_38_]

Need to combine first and last name from two columns
 
Rob,

Nice, worked great.

Thanks again,
Dave


"Rob van Gelder" wrote in message
...
Dave,

Sub testit()
Dim i As Long, lngLastRow As Long

With Sheet1
lngLastRow = .Cells(1, 1).End(xlDown).Row
For i = 1 To lngLastRow
.Cells(i, 3) = .Cells(i, 1) & ", " & .Cells(i, 2)
Next
End With
End Sub


Rob

"Dave" wrote in message
...
This is what I have. I need some help as indicated in the comments:

Sub Combine()

Do ' Outer loop.

ActiveCell.Select
last = ActiveCell.Formula

'need to move one cell to the right here

ActiveCell.Select
first = ActiveCell.Formula

'need to move one cell to the right here

ActiveCell.FormulaR1C1 = last + ", " + first

' need to move back to column one here

' need to move down one row here

Loop Until EOF 'Will this stop at the first empty value in column one?

End Sub


Thank you in advance.








All times are GMT +1. The time now is 01:16 PM.

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