ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Join text (https://www.excelbanter.com/excel-programming/353227-join-text.html)

thanhnguyen[_11_]

Join text
 

Dear all

I would like to write an macro which will be join value of 3 columns
into 1 column.

Example:

A1 = "A"
B1 = "B"
C1 = "C"

A2 = "X"
B2 = "Y"
C2= "Z"

After run this macro then
A1= "ABC"
B1= ""
C1= ""

A2="XYZ"
B2=""
C2=""

Please guide me how to do that!

Many thanks

Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile: http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=512135


Norman Jones

Join text
 
Hi Thanh,

Try:
'=============
Public Sub Tester1()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim rCell As Range
Dim LRow As Long
Dim CalcMode As Long

Set WB = ActiveWorkbook '<<==== CHANGE
Set SH = WB.Sheets("Sheet2") '<<==== CHANGE

LRow = Cells(Rows.Count, "A").End(xlUp).Row

Set Rng = Range("A2:A" & LRow)

On Error GoTo XIT

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

For Each rCell In Rng.Cells
With rCell
.Value = .Value & .Offset(0, 1).Value & .Offset(0, 2).Value
.Offset(0, 1).Resize(1, 2).ClearContents
End With
Next rCell

XIT:
With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With

End Sub
'<<=============


---
Regards,
Norman


"thanhnguyen"
wrote in message
...

Dear all

I would like to write an macro which will be join value of 3 columns
into 1 column.

Example:

A1 = "A"
B1 = "B"
C1 = "C"

A2 = "X"
B2 = "Y"
C2= "Z"

After run this macro then
A1= "ABC"
B1= ""
C1= ""

A2="XYZ"
B2=""
C2=""

Please guide me how to do that!

Many thanks

Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile:
http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=512135




thanhnguyen[_12_]

Join text
 

Hi Norman
Thanks so much, very great!

Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile: http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=512135



All times are GMT +1. The time now is 11:18 AM.

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