Excel VBA Macro: Delete All Sheets that Contain a Certain Text (String) Value

  Рет қаралды 927

greggowaffles

greggowaffles

Жыл бұрын

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

Пікірлер: 6
@odijin
@odijin Жыл бұрын
Bro, this video saved my whole life!!! I can't even thank you enough. Super appreciate this tutorial and your other videos as well. Been studying your catalog of videos and learning massively. The best part is how you describe each line of code and what they actually do, and also how you explain the complex parts, so anybody can follow the coding logic. That helps a lot. This is some straight up on point Excel VBA skills you're showing us here, no cap! Thank you again Greg. Liked and subscribed. Looking forward to your next videos!
@greggowaffles
@greggowaffles Жыл бұрын
Thank you so much for the kind words!! It means a lot!! Happy to help!!
@justinstone1401
@justinstone1401 9 ай бұрын
I used the exact same code you provided in the video. The problem I am having is that when I run the macro the first time it will only delete 5 tabs, when I run it a second time it will delete 2 tabs and I have to keep running it until it’s suppose to delete all the tabs to work properly. Would anyone know why this is happening to me?
@ayrarosli9114
@ayrarosli9114 9 ай бұрын
Hi there! how about if i want to delete the rows that contains "turtle soup instead" ? how would the program differ?
@alexrosen8762
@alexrosen8762 Жыл бұрын
Wow! You deliver all the time man. I work as a business controller and situations like this tutorial pops up every now and then so very useful tutorial
@greggowaffles
@greggowaffles Жыл бұрын
Appreciate the continued support!!
New model rc bird unboxing and testing
00:10
Ruhul Shorts
Рет қаралды 28 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 18 МЛН
How to Get List of File Names in a Folder using Excel
5:40
Excel Weez
Рет қаралды 6 М.
Excel VBA Macro: Right Align Image in Email Body (and Resize)
11:14
greggowaffles
Рет қаралды 1,1 М.
Excel VBA Macro: Delete Rows (Based on List of Values)
12:22
greggowaffles
Рет қаралды 605
Excel VBA Macro: Save Range (as Image) and Attach to Email
12:15
Excel VBA Macro: Send Multiple Emails (with Multiple Attachments)
12:09
Bulk Outlook Emails with CC and Attachments and Priority using Excel VBA
14:44
Split one excel sheet into multiple sheets based on column value
1:50
Improve Your Excel
Рет қаралды 93 М.
New model rc bird unboxing and testing
00:10
Ruhul Shorts
Рет қаралды 28 МЛН