0
votes

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?

1
Where exactly do you want to paste the copied row? If you use WorkSheet.PasteSpecial in stead of Range.PasteSpecial it will paste to whatever is the activecell. - Tim Williams

1 Answers

1
votes

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

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