Ninja Dude
Ninja Dude

Reputation: 1392

Object doesn't support this property vba

'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

Upvotes: 3

Views: 508

Answers (1)

Shai Rado
Shai Rado

Reputation: 33682

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.

Upvotes: 2

Related Questions