Delete Sheets Problem

J

joecrabtree

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
 
J

james.billy

Hi,

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

James
 
B

Bob Phillips

Worked fine for me as written.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top