Checking all sheets except 1

  • Thread starter Patrick C. Simonds
  • Start date
P

Patrick C. Simonds

Is there any way to amend this code so that it checks all sheets except the
sheet named Holidays


Private Sub testdelete()

'Clears Picture when changing the Year

'Application.ScreenUpdating = False

For n = 1 To Sheets.Count
With Sheets(n)
Set myPict = Nothing
On Error Resume Next
Set myPict = .Pictures("New Years Large")
On Error GoTo 0

If myPict Is Nothing Then
'not on this sheet
Else
myPict.Delete
Range("F2").Value = ""
'exit for 'stop looking on other sheets??????
End If
End With
Next n
End Sub
 
O

OssieMac

Hi Patrick,

Private Sub testdelete()

'Clears Picture when changing the Year

'Application.ScreenUpdating = False

For n = 1 To Sheets.Count
If Sheets(n).Name <> "Holidays" Then
With Sheets(n)
Set myPict = Nothing
On Error Resume Next
Set myPict = .Pictures("New Years Large")
On Error GoTo 0

If myPict Is Nothing Then
'not on this sheet
Else
myPict.Delete
Range("F2").Value = ""
'exit for 'stop looking on other sheets??????
End If
End With
End If
Next n
End Sub
 
G

Gord Dibben

Private Sub testdelete()

'Clears Picture when changing the Year

'Application.ScreenUpdating = False

For n = 1 To Sheets.Count

With Sheets(n)
If Not .Name = "Holidays" Then 'add this line
Set myPict = Nothing
On Error Resume Next
Set myPict = .Pictures("New Years Large")
On Error GoTo 0

If myPict Is Nothing Then
'not on this sheet
Else
myPict.Delete
.Range("F2").Value = "" 'note the dot before Range
'exit for 'stop looking on other sheets??????
End If
End If 'add this line
End With
Next n
End Sub


Gord Dibben MS Excel MVP
 

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