I would like to create a Macro that goes through each sheet in my workbook (except the sheets: "Control Panel" and "Master") and finds the word "Hook: #####". Then, if that sheet contains the word hook I would like the macro to then delete it.
There is another condition. I only want it to delete sheets that have the word "Hook:" with numbers after it, NOT text. Example
Hook: 78945757 - Delete this sheet
Hook: Unknown - do not delete this sheet
Below is all I have right now, I'm not very good with loop codes - please help!
Sub FindTrailersandDelete()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
Dim CopyRng As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
' Loop through all worksheets and delete ones with a trailer #
For Each sh In ActiveWorkbook.Worksheets
On Error Resume Next
Sheets(1).Rows.Find(what:="Hook:", lookat:=xlPart).EntireSheet.Delete
On Error GoTo 0
Next
Application.DisplayAlerts = True
End Sub
There is another condition. I only want it to delete sheets that have the word "Hook:" with numbers after it, NOT text. Example
Hook: 78945757 - Delete this sheet
Hook: Unknown - do not delete this sheet
Below is all I have right now, I'm not very good with loop codes - please help!
Sub FindTrailersandDelete()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
Dim CopyRng As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
' Loop through all worksheets and delete ones with a trailer #
For Each sh In ActiveWorkbook.Worksheets
On Error Resume Next
Sheets(1).Rows.Find(what:="Hook:", lookat:=xlPart).EntireSheet.Delete
On Error GoTo 0
Next
Application.DisplayAlerts = True
End Sub