• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

CopyPaste into table

Villalobos

Active Member
Hello,

I use this code to copy and paste data into Table1:

Code:
 Sub CopyPasteData()
    Dim lastrow As Long
        lastrow = Sheets("Sheet2").Range("B65536").End(xlUp).Row + 1
                Range("A14:C" & lastrow).Copy
                Sheets("Sheet2").Range("B" & lastrow).PasteSpecial xlPasteValues
End Sub

and after the pasting the range of Table1 is extended with blank rows and I do not know why. Please, could someone help me where I made a mistake and how should avoid that?

Thanks in advance the reply!
 

Attachments

  • CopyPaste problem.xlsm
    20.4 KB · Views: 4
Hi,

Check with below code.It's due to last row.

Code:
Sub CopyPasteData()
    Dim lastrow As Long, lrow As Long
    Application.ScreenUpdating = False
        lrow = Sheets("Sheet1").Range("B65536").End(xlUp).Row
        lastrow = Sheets("Sheet2").Range("B65536").End(xlUp).Row + 1
                Sheets("Sheet1").Range("A14:C" & lrow).Copy
                Sheets("Sheet2").Range("B" & lastrow).PasteSpecial xlPasteValues
                Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Back
Top