Delete multiple rows across multiple sheets containing the same keyword

kurosaki4d

New Member
Joined
Jul 30, 2019
Messages
1
I have an excel file that contains around 50 sheets, all sheets have the same columns.
However, i would like to delete the entire rows that contains the same keyword "MARTIN" located in the 6th/last column in all the sheets.
I have tried to select all sheets at once and then delete the rows but it only worked for one sheet.
So if there is a way to do that either through an excel option or vba i'm all ears to suggestions.
Thank you
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Assuming that you have header rows in each sheet then maybe...

Code:
Sub Filterit()
    Dim sht As Worksheet
    Application.ScreenUpdating = False
    For Each sht In ActiveWorkbook.Worksheets
        With sht.Range("A1:F" & sht.Range("A" & Rows.Count).End(xlUp).Row)
            .AutoFilter 6, "MARTIN"
        
            On Error Resume Next
            .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
            On Error GoTo 0
            .AutoFilter
        End With
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Is 'MARTIN' a stand alone value or is it embedded in other text?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top