copy 2 columns and paste to one

  • Thread starter Thread starter Jonah
  • Start date Start date
J

Jonah

I am wanting to create a macro that will copy the contents
of two columns from one sheet and paste them into a single
column in another sheet. That is easy enough except as
the two source columns grow with new data, my macro will
miss the recent additions.
Did that make sense?
 
One way - This will create a new sheet called summary with your data on it.
Just change the A and B for the columns you want to combine. It will delete the
sheet called summary and recreate it every time you run it - No warnings.

Sub CombineData()

Dim SumSht As Worksheet
Dim SrcSht As Worksheet
Dim LastRow As Long
Dim i As Long

Application.ScreenUpdating = False
Set SrcSht = ActiveSheet
Set SumSht = Worksheets.Add

On Error Resume Next
Application.DisplayAlerts = False
Sheets("Summary").Delete
SumSht.Name = "Summary"
Application.DisplayAlerts = True

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

For i = 1 To LastRow
With SumSht.Cells(i, "A")
.Value = SrcSht.Cells(i, "A") & SrcSht.Cells(i, "B")
End With
Next i

Application.ScreenUpdating = True
End Sub
 
Back
Top