![]() |
copy method of worksheet class failed: trying to copy a hidden she
I got a "copy method of worksheet class failed" error when trying to copy
sheet2. Sheet2 is hidden. here is the code: Sheets("Sheet2").Copy Thanks in advance |
copy method of worksheet class failed: trying to copy a hidden she
You will get that message when you copy a hidden sheet without specifying
Befo= or After:=. If the sheet is not hidden, it will create a new workbook with only that sheet in it. "sam" wrote in message ... I got a "copy method of worksheet class failed" error when trying to copy sheet2. Sheet2 is hidden. here is the code: Sheets("Sheet2").Copy Thanks in advance |
copy method of worksheet class failed: trying to copy a hidden she
If you goto the doctor and say "it hurts when I do this", the doctor might
say "Dont do that" -- Don Guillett Microsoft MVP Excel SalesAid Software "sam" wrote in message ... I got a "copy method of worksheet class failed" error when trying to copy sheet2. Sheet2 is hidden. here is the code: Sheets("Sheet2").Copy Thanks in advance |
copy method of worksheet class failed: trying to copy a hidden she
P.Sl
For best results, unhide the worksheet to copy it, then re-hide it if needed. Otherwise, you can get some strange results. "sam" wrote in message ... I got a "copy method of worksheet class failed" error when trying to copy sheet2. Sheet2 is hidden. here is the code: Sheets("Sheet2").Copy Thanks in advance |
copy method of worksheet class failed: trying to copy a hidden she
When you don't specify a parameter after the Copy method, a copy of
the worksheet is created as the only worksheet in a newly created workbook. However, a workbook must contain at least one visible worksheet. Your code fails because it instructs Excel to create a new workbook with no visible worksheet. Try Application.ScreenUpdating = False With ThisWorkbook.Worksheets("Sheet2") .Visible = True .Copy .Visible = False '''' ' At this point, the newly created workbook containing ' only Sheet2 is the visible ActiveWorkbook. To return ' back to the original workbook, uncomment the line below: '''' '.Parent.Activate End With Application.ScreenUpdating = True Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 7 Aug 2009 15:15:01 -0700, sam wrote: I got a "copy method of worksheet class failed" error when trying to copy sheet2. Sheet2 is hidden. here is the code: Sheets("Sheet2").Copy Thanks in advance |
All times are GMT +1. The time now is 04:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com