copy 2 columns and paste to one

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?
 
K

Ken Wright

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
 

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

Top