VBA: Append rather than copy over

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
840
Hello I have the following code which copies from one sheet and pastes from Row 8 in the next. Each time I run the macro it copies over, I would like to change it to append the data.

Any thoughts, thanks.

Code:
Sub Add_to ()


Application.ScreenUpdating = False


Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
Sheets("Comparison").Activate
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Lastrowa = 8
    For i = 1 To Lastrow
        If Sheets("Comparison").Cells(i, "L").Value = "True" Then
            Sheets("Comparison").Range(Cells(i, "B"), Cells(i, "I")).Copy
            Sheets("My List").Range("B" & Lastrowa).PasteSpecial xlPasteValues
            Lastrowa = Lastrowa + 1
        End If
    
    Next


Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi there. Change
Code:
Lastrowa = 8
to
Code:
Lastrowa = Sheets("My List").Cells(Rows.Count, "B").End(xlUp).Row+1
 
Upvote 0
How about
Code:
Lastrowa = Sheets("My List").Cells(Rows.Count, "B").End(xlUp).Row+1
if Lastrowa<8 then Lastrowa=8
 
Upvote 0
How about
Code:
Lastrowa = Sheets("My List").Cells(Rows.Count, "B").End(xlUp).Row+1
if Lastrowa<8 then Lastrowa=8

Thanks Fluff, so the first submission populates from row 8.

Then the second leaves a gap of 2 rows, not dependent on the number of rows I am copying.
 
Upvote 0
No, if there is nothing in col B after row 7, it will paste in row 8, otherwise it will paste in the row below the last row.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,123
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top