Home » excel » excel – Object doesn't support this property vba

excel – Object doesn't support this property vba

Posted by: admin April 23, 2020 Leave a comment

Questions:
'Copy and Paste the format of table
        With wb.Sheets("Sheet1").UsedRange
            .Copy
        End With

        Set cell = ActiveSheet.Range("C" & Rows.Count).End(xlUp)
        cell.Offset(3, 3).Activate

        With wbTarget.Sheets(I).ActiveCell
            .PasteSpecial
        End With

On the 3rd paragraph, it gives me the error. I want to paste the contents that I copied into the activecell.

How can I fix this? thanks

How to&Answers:

If I understand what you are trying to achieve with your code, I think ActiveSheet is also wbTarget.Sheets(I) (I hope).

So replace your:

Set cell = ActiveSheet.Range("C" & Rows.Count).End(xlUp)
cell.Offset(3, 3).Activate

With wbTarget.Sheets(I).ActiveCell
    .PasteSpecial
End With

With:

With ActiveSheet
    Set cell = .Range("C" & .Rows.Count).End(xlUp)
    cell.Offset(3, 3).PasteSpecial
End With

Note: You should stay away from ActiveSheet and use the Worksheets("SheetName") instead.