Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Delete Sheets Problem

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Delete Sheets Problem

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Delete Sheets Problem

Worked fine for me as written.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"joecrabtree" wrote in message
ups.com...
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
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
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 04:38 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM
Delete Sheets Problem Edgar Thoemmes[_4_] Excel Programming 3 October 27th 04 12:32 PM


All times are GMT +1. The time now is 02:14 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"