Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy method of Worksheet class failed Chaplain Doug Excel Programming 4 March 15th 07 09:24 PM
Copy method of worksheet class failed NHRunner[_2_] Excel Programming 3 November 28th 06 06:01 PM
Copy method of worksheet class failed - help! Chet Shannon[_4_] Excel Programming 11 April 10th 06 05:18 AM
Copy method of Worksheet class failed Francis Brown Excel Programming 1 October 26th 05 08:22 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 2 April 7th 04 01:43 PM


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"