Cheers Fazza
I thought that would delete all sheets but it worked a treat as long as the sheets weren't hidden as these are. Is there a way to delete them even if hidden ?
Forgive me keep coming back but I thought I'd keep the main question brief nut hadn't realised the other problems.
END
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
Dim FoundTemp As Boolean
For Each ws In Worksheets
If UCase(Left(ws.Name, 4)) = "TEMP" Then
If MsgBox("Would you like to delete the sheet: " & ws.Name & "?", vbYesNo, "Delete sheet?") = vbYes Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If
End If
Next
End Sub
Sub test()
Dim ws As Worksheet
If vbYes <> MsgBox("Delete all Temp sheet?", vbYesNo + vbQuestion) Then Exit Sub
On Error Resume Next
Application.DisplayAlerts = False
For Each ws In Sheets
If LCase(ws.Name) Like "temp*" Then ws.Delete
Next
Application.DisplayAlerts = True
End Sub