ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy method of Worksheet class failed (https://www.excelbanter.com/excel-programming/343920-copy-method-worksheet-class-failed.html)

Francis Brown

Copy method of Worksheet class failed
 
Hello I Have the following code:

Worksheets("Data History").Copy after:=Worksheets("Adviser")

and if produces this error:

Run-time error '1004':

Copy method of Worksheet class failed

Both Sheets referenced in the code exist in the workbook. Any Ideas why this
is happening. It only started recently. The code worked before.

Regards and thanks for all help.

Francis.





Francis Brown

Copy method of Worksheet class failed
 
Hello.
I solved my own problem.
entered line:
Worksheets("Data History").Activate
before the offending line and code now works.

? Why does it need this as the Worksheet is referenced explicitly.

Regards

Francis.

"Francis Brown" wrote:

Hello I Have the following code:

Worksheets("Data History").Copy after:=Worksheets("Adviser")

and if produces this error:

Run-time error '1004':

Copy method of Worksheet class failed

Both Sheets referenced in the code exist in the workbook. Any Ideas why this
is happening. It only started recently. The code worked before.

Regards and thanks for all help.

Francis.






All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com