Reputation: 1392
'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
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