user5857081
user5857081

Reputation:

Error: PasteSpecial method 2013

I'm trying to copy and paste the values form another workbook with the specific sheet named Sheet1. But when I run this code:

Dim wb as Workbook
Dim conso as Worksheet
set conso = wb.Worksheets("Sheet1")

    With conso
        .Rows(1).EntireRow.Copy
    End With

    With ActiveSheet
        '.Paste
        .PasteSpecial xlPasteColumnWidths
        .PasteSpecial xlPasteFormats
        .PasteSpecial xlPasteValues
    End With

I got an error saying:

PasteSpecial method of Worksheet class failed.

I'm trying to copy all the entire row of the Sheet1 sheet to another workbook. Any help?

Upvotes: 0

Views: 290

Answers (1)

lenwe
lenwe

Reputation: 100

Try indicating where you need to paste the cells you copied:

With ActiveSheet.Rows(1)
    '.Paste
    .PasteSpecial xlPasteColumnWidths
    .PasteSpecial xlPasteFormats
    .PasteSpecial xlPasteValues
End With

Upvotes: 1

Related Questions