Macro - Paste into next empty row

stusam

New Member
Joined
Apr 6, 2022
Messages
8
Office Version
  1. 2019
Platform
  1. Windows
Hi.

I'm looking for advice on how to update my simple macro. I would like it to copy selected data from Sheet 1, and paste into the next empty row in Sheet 2, before deleting it from sheet 1.

Here's what I have so far:

Range("B2:F2").Select
Selection.Copy
Sheets("Sheet 2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet 1").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub

Is anyone able to help explain what instruction is needed to ensure the data is pasted into the next empty row?

Thank you.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try:
VBA Code:
Sub CopyRange()
    With Sheets("Sheet1")
        .Range("B2:F2").Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1)
        .Range("B2:F2").ClearContents
    End With
End Sub
 
Upvote 0
Try:
VBA Code:
Sub CopyRange()
    With Sheets("Sheet1")
        .Range("B2:F2").Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1)
        .Range("B2:F2").ClearContents
    End With
End Sub

Thank you for such a quick response. I tried the code but I'm getting am "Out of range" error. The debugger points to the "With Sheets(Sheet1")" line as causing the issue. This is my first time dabbling with VBA, so it's almost certainly something I'm doing wrong. Here's a simplified version of my file with my original code. If you are able to look at it for me, I'd be most grateful.
 
Upvote 0
Oops!! Put a space between "Sheet" and the number in the code.
Sheet 1
Sheet 2
 
Upvote 0

Forum statistics

Threads
1,223,763
Messages
6,174,359
Members
452,558
Latest member
jswan83

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