PC Review


Reply
Thread Tools Rate Thread

Delete Sheets Problem

 
 
joecrabtree
Guest
Posts: n/a
 
      18th Dec 2006
To all,

I have this code that deletes all but the active worksheets. This
deletes the sheets fine, but then returns the error:

Method 'Delete' of Object_ Worksheets Failed

Any ideas why this is happening?

The code is below:

Dim wks As Worksheet


Application.DisplayAlerts = False
For Each wks In Worksheets
If wks.Name <> ActiveSheet.Name Then wks.Delete
Next wks
Application.DisplayAlerts = True


Thanks in advance for your help,

Regards

Joseph Crabtree

 
Reply With Quote
 
 
 
 
james.billy@gmail.com
Guest
Posts: n/a
 
      18th Dec 2006
Hi,

I have come across this before when trying to delete a sheet that
wasn't visible, is this possible?

James

joecrabtree wrote:
> To all,
>
> I have this code that deletes all but the active worksheets. This
> deletes the sheets fine, but then returns the error:
>
> Method 'Delete' of Object_ Worksheets Failed
>
> Any ideas why this is happening?
>
> The code is below:
>
> Dim wks As Worksheet
>
>
> Application.DisplayAlerts = False
> For Each wks In Worksheets
> If wks.Name <> ActiveSheet.Name Then wks.Delete
> Next wks
> Application.DisplayAlerts = True
>
>
> Thanks in advance for your help,
>
> Regards
>
> Joseph Crabtree


 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Dec 2006
Worked fine for me as written.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"joecrabtree" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> To all,
>
> I have this code that deletes all but the active worksheets. This
> deletes the sheets fine, but then returns the error:
>
> Method 'Delete' of Object_ Worksheets Failed
>
> Any ideas why this is happening?
>
> The code is below:
>
> Dim wks As Worksheet
>
>
> Application.DisplayAlerts = False
> For Each wks In Worksheets
> If wks.Name <> ActiveSheet.Name Then wks.Delete
> Next wks
> Application.DisplayAlerts = True
>
>
> Thanks in advance for your help,
>
> Regards
>
> Joseph Crabtree
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add and Delete sheets Risky Dave Microsoft Excel Programming 3 10th Dec 2008 05:33 PM
Re: Macro to delete sheets and saves remaining file does not properly delete module gazornenplat Microsoft Excel Programming 0 22nd Jun 2005 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Microsoft Excel Programming 7 21st Jun 2005 05:16 PM
Delete Sheets Problem =?Utf-8?B?RWRnYXIgVGhvZW1tZXM=?= Microsoft Excel Programming 3 27th Oct 2004 12:32 PM
delete all sheets except... caroline Microsoft Excel Programming 4 22nd May 2004 04:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:16 PM.