View Full Version : [SOLVED:] Combining two cells into One
austenr
12-03-2004, 03:51 PM
I don't believe I have seen the code for this anywhere but if someone knows where it might be let me know.
I have two cells that have a last name and a first name in them. I need to combine them into one cell, last name then a space then the first name. If anyone has any ideas please let me know. Thanks
Zack Barresse
12-03-2004, 03:58 PM
Hey,
You could use something like this ...
Option Explicit
Sub CreateFullName()
Dim cel As Range, rng As Range
Set rng = Range("A2:A10")
For Each cel In rng
cel.Offset(, 2).Value = cel.Value & " " & cel.Offset(, 1).Value
Next cel
End Sub
This is assuming some things. 1) Your range of Last Names are in A2:A10. 2) Your first names are in the corresponding rows in column B. 3) You have nothing in the corresponding rows of column C as that's where the concatenated values go. A formula would look like ...
=A2&" "&B2
Zack Barresse
12-03-2004, 04:00 PM
A possibly faster way also ...
Option Explicit
Sub CreateFullName()
With Range("C2:C10")
.FormulaR1C1 = "=RC[-2]&"" ""&RC[-1]"
.Value = .Value
End With
End Sub
Making the same assumptions..
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.