Delete rows in each workbook based on keyword match specific column

satish78

Board Regular
Joined
Aug 31, 2014
Messages
218
Hi Friends,

I looked in to forum posts where I am looking to delete rows with keyword match in specific column(like ColumnI) in multiple workbooks in a folder.
I want use VBA to delete entire row of each workbook in folder (there are 100+ workbooks in a folder) based on keyword match(keyword is "incomplete") in ColumnI.
Vba should loop through list of workbooks in a folder.

Thanks
 
Try:
Rich (BB code):
Sub DeleteRows()
    Application.ScreenUpdating = False
    Dim srcWB As Workbook
    Const strPath As String = "F:\Records\"
    ChDir strPath
    strExtension = Dir(strPath & "*.csv")
    Do While strExtension <> ""
        Set srcWB = Workbooks.Open(strPath & strExtension)
        With Sheets("Sheet1")
            .Range("A1").CurrentRegion.AutoFilter 9, "incomplete"
            .AutoFilter.Range.Offset(1).EntireRow.Delete
            .Range("A1").AutoFilter
        End With
        Application.DisplayAlerts = False
        srcWB.SaveAs Filename:="F:\Uniquerecords\" & srcWB.Name, FileFormat:=xlCSV, CreateBackup:=False
        Application.DisplayAlerts = True
        srcWB.Close False
    Loop
    Application.ScreenUpdating = True
End Sub
Change the sheet name (in red) to suit your needs.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
In every workbook only one sheet available. That is name is not same as Sheet1 in every workbook. They are dynamic.
 
Upvote 0
Replace:
VBA Code:
With Sheets("Sheet1")
with
VBA Code:
With Sheets(1)
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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