Paste method error in macro
Try something like this instead of all of those selects:
Sub test()
With Sheets("x")
.Columns(1).Delete Shift:=xlToLeft
With .Cells
.EntireColumn.AutoFit
.AutoFilter Field:=22, Criteria1:="GR"
.SpecialCells(xlCellTypeVisible).Copy _
Sheets("GR_fast_movers_not_in_talls") _
.Range("A1")
End With
.AutoFilterMode = False
End With
End Sub
bwilk77 wrote:
I have a macro that is trying to copy certain from one sheet and paste it
into a different sheet (both in the same workbook). For the most part this
is working, except when it is run on one specific computer, I get the error
1004 "Paste method of worksheet class failed". Why would this only happen on
one particular computer?
Here is the code that is erroring out.
Sheets("x").Select
Range("A1").Select
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
Cells.EntireColumn.AutoFit
Selection.AutoFilter Field:=22, Criteria1:="GR"
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("GR_fast_movers_not_in_talls").Select
Range("A1").Select
ActiveSheet.Paste
Thanks, Brad
|