Sub Kayslover()
Dim sh As Worksheet
'Application.DisplayAlerts = 0 'uncomment these commented lines to delete sheet without confirmation
On Error Resume Next
For Each sh In Worksheets
If ThisWorkbook.Sheets("Formula").Range("H2") = 4 Then Sheets("Sheet5").Delete
Next sh
'Application.DisplayAlerts = 1
End Sub
Sub CheckAndDelete()
If Sheets("Formula").Range("H2").Value = 4 Then
Application.DisplayAlerts = False
On Error Resume Next
Sheets("Sheet5").Delete
On Error GoTo 0
Application.DisplayAlerts = True
End If
End Sub
We don't. That is exactly what I wrote in post #3why do we have to have a loop to cycle throught the whole workbook?
There is no need/reason to cycle through all the worksheets.
Sub CheckAndDelete()
If Sheets("Formula").Range("H2").Value = 4 Then
Application.DisplayAlerts = False
On Error Resume Next
Sheets("Sheet5").Delete
On Error GoTo 0
Application.DisplayAlerts = True
MsgBox "Sheet5 deleted"
Else
MsgBox "Sheet5 not deleted"
End If
End Sub