![]() |
Paste method error in macro
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 |
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 |
Paste method error in macro
This worked on my computer, but again I got an error on that particular PC.
This error was "Run time error: Copy method of range class failed" This errored out at this line: .SpecialCells(xlCellTypeVisible).Copy _ Sheets("GR_fast_movers_not_in_talls") _ .Range("A1") Any thoughts??? Thanks, "JW" wrote: 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 |
All times are GMT +1. The time now is 03:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com