I have a VBA code that is getting a 1004 error when pasting visible cells:
PasteSpecial method of Range class failed
I can comment out the paste and it will copy the visible cells so I can manually paste them, but the automated paste causes the error. I have confirmed that the sheet names are correct and have tried various types of paste special and just .Paste
.
This is my code:
'Copies Column A visible rows
Sheets("Sheet1").Range("$A$2:$A$" & lastRow).SpecialCells (xlCellTypeVisible).Copy
'Empties sheet
Sheets("Sheet2").Cells.ClearContents
'Pastes to sheet2
Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues
Can anyone suggest a solution?