View Full Version : [SOLVED:] Concatenate Two Cells in a third cell
sharc316
03-22-2017, 06:04 PM
Hi,
This seems like a simple procedure but just cannot get this to work right. I would like to concatenate two fixed cells into the third cell.
For example:
Cell A1=Hello
Cell A2=World
Cell A3= Hello World
Thank you.
mdmackillop
03-22-2017, 06:16 PM
=A1 & " " & A2
sharc316
03-22-2017, 06:30 PM
Thank you mdmackillop. But how would I do this in VBA? This would be part of a Macro.
Paul_Hossler
03-22-2017, 06:53 PM
Range("A3").Value = Range("A1").Value & Range("A2").Value
mdmackillop
03-22-2017, 07:26 PM
... and with a space between
Range("A3").Value = Range("A1").Value & " " & Range("A2").Value
sharc316
03-22-2017, 07:26 PM
thanks Paul. I have it in a file with multiple works sheets. These cells are located on shee1. I'm putting Sheets("Sheet1") in front of your code but cant seem to make i work. Would this be the right approach?
Paul_Hossler
03-23-2017, 11:22 AM
Expanding on Mac's ...
Without explicitly specifying a worksheet, as is it will use whatever the ActiveSheet is
This is specific to Sheet1
Worksheets("Sheet1").Range("A3").Value = Worksheets("Sheet1").Range("A1").Value & " " & Worksheets("Sheet1").Range("A2").Value
or to save a little typing
With Worksheets("Sheet1")
.Range("A3").Value = .Range("A1").Value & " " & .Range("A2").Value
End With
sharc316
03-23-2017, 04:14 PM
Thank you Paul!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.