Recording a Macro that Copies & Pastes into Other Sheets

carrieebacon

New Member
Joined
Jan 15, 2024
Messages
49
Office Version
  1. 365
Platform
  1. Windows
Hi! I am trying to record a macro that will copy column A through column J from Sheet 1 and paste into column A through column J in Sheet 2. The problem is, I have frozen Row 1 through Row 5 and need the data to paste into Row 6. It will not let me paste into a specific cell, only a column. The data that will be copied and pasted is coming from imported csv files that will differ in length, so some might have 20 rows and others might have 50. That is why I chose to copy columns. (BTW, I figured out how to do it while messing around with it, then once I went to record the macro, I completely forgot how I did it so I know it's possible lol.) Also, is there anything I can set up so that when I run the macro, future data that will be copied and pasted will go to the last row underneath existing data? Thank you!!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
try this

VBA Code:
Sub CopyDataToSheet2()
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim lastRow As Long

    Set ws1 = ThisWorkbook.Sheets("Sheet1")
    Set ws2 = ThisWorkbook.Sheets("Sheet2")

    lastRow = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row

    ws1.Range("A1:J100").Copy ws2.Cells(lastRow + 1, 1)
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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