VBA Code to copy Sheet1 to Sheet2 and paste in Row 2

rrickard

New Member
Joined
Jul 25, 2017
Messages
17
I need to copy Sheet 1 to Sheet 2 and paste special starting in Row 2 on Sheet 2.

The data on sheet 1 could change (# of rows & columns). I just want the paste special to start in row 2 of Sheet 2 so that row 1 doesn't get overwritten.

If I need to define the columns I probably could, but the row data will expand and shrink over time.

I have been using the below code, but it copies all cells between sheets impacting row 1 on Sheet 2 (which I don't want).

Sub Button1_Click()

Application.ScreenUpdating = False
Sheets("Sheet1").Cells.Copy
Sheets("Sheet2").Cells(1, 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ThisWorkbook.Worksheets("Sheet2").Cells.EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub
 
What if I want to stay on Sheet2 after the copy? Using footoo's code after the script it returns me to Sheet 1 (I have a button on Sheet2 that executes the copy).

Code:
Sub Button1_Click()
Application.ScreenUpdating = False
Range([A2], Cells(Rows.Count, Columns.Count)).ClearContents
Sheets("Sheet1").Activate
Range([A1], ActiveSheet.UsedRange).Copy
Sheets("Sheet2").Activate
Cells(2, 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Cells.EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub
 
Upvote 0

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.

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

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