Join text

  • Thread starter Thread starter thanhnguyen
  • Start date Start date
T

thanhnguyen

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
 
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" <[email protected]>
wrote in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top