View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] ucanalways@gmail.com is offline
external usenet poster
 
Posts: 115
Default Delete sheet on a condition: debug error

I have the following code.

The following sub is written for deleting a worksheet that has its
name as 0. Code works but I dont get the desired result.

Sub test1()

Dim ws as worksheet

For each ws InThisWorkbook.Worksheets

If ws.name = 0 then
Application.DisplayAlerts = False
ws.delete
End If

Next

End Sub

The following sub is written for deleting worksheets if its index
number is greater than 3. Again, Code works but dont get the desired
result.

Sub test2()
Dim ws as worksheet

For each ws InThisWorkbook.Worksheets
Application.DisplayAlerts = False
If ws.index 3 then
ws.delete
End If

Next

End Sub

Any idea why this happens? Thanks