Excel VBA Macro: Delete All Sheets that Contain a Certain Text (String) Value
💥Subscribe: / @greggowaffles
Code:
Sub delete_sheets_containing_value()
Dim i As Integer
Dim tab_count As Integer
Dim my_string As String
tab_count = Sheets.Count
i = 1
Do While i <= tab_count
my_string = Sheets(i).Cells(1, 1)
If InStr(my_string, "Turtle Soup") > 0 And tab_count > 1 Then
Application.DisplayAlerts = False
Sheets(i).Delete
Application.DisplayAlerts = True
tab_count = Sheets.Count
End If
i = i + 1
Loop
#excelmacro #excelvba
End Sub