View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Code not doing what I hoped for

untested, but give it a try

Sub HolidayRemove()

Dim n As Long

For n = 1 To Sheets.Count
If Sheets(n).Name < "Holidays" Then
With Sheets(n)
.Activate
.Unprotect
.Shapes.SelectAll
Selection.Delete
.Range("K1").Value = ""
.Protect
End With
End If

Next n


End Sub


--


Gary

"Patrick C. Simonds" wrote in message
...
Can anyone tell me why the code below only works on the worksheet that's
active when it is run? My hope was that it would go to each worksheet
(excluding Holidays) and remove all shapes and clear the value in cell F1

Sub HolidayRemove()

Protection.UnProtectAllSheets

For n = 1 To Sheets.Count
If Sheets(n).Name < "Holidays" Then
With Sheets(n)

ActiveSheet.Shapes.SelectAll
Selection.Delete
Range("K1").Value = ""

End With
End If

Next n

Protection.ProtectAllSheets
End Sub