VBA - copy and paste onto the next empty cell

macroos

New Member
Joined
May 30, 2018
Messages
45
Hi All.

I was wondering how to paste some selected data that I copied from Sheet1 onto Sheet2 in the same workbook on the next cell that is blank.

So far, I have the following codes:

Sub Step4()
Sheets("Sheet1").Select
Range("B1:L34").Select
Selection.Copy
Sheets("Sheet2").Select
Range("B" & Rows.Count).End(xlUp).Offset (1) To look for the first empty cell in column B
ActiveSheet.Paste
Range("A1").Select
End Sub

I know something is wrong in the searching for the first empty cell and pasting the copied data, but I'm not sure how to fix it.

Thank you in advance.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
try this:

Code:
Option Explicit


Sub Step4()
    Dim s1 As Worksheet, s2 As Worksheet
    Set s1 = Sheets("Sheet1")
    Set s2 = Sheets("Sheet2")
    Dim lr As Long
    lr = s2.Range("B" & Rows.Count).End(xlUp).Row    'finds last row in column B
    s1.Range("B1:L34").Copy s2.Range("B" & lr + 1)    'assumes you wish to start paste in column B
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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