Delete Rows Macro on mutiple sheets

BradH

New Member
Joined
Jan 25, 2010
Messages
44
I have a workbook with about 120 sheets. I need a macro/vba that will search through half of these sheets and delete the entire row if it contains #N/A. The other half of these sheets also contain the #N/A, but I don't want it deleted in them.

Thanks
 
This did nothing.
Oops, slight typo, it should be
Code:
Sub test()

    Dim i As Long
    
    Application.ScreenUpdating = False
    
    For i = 66 To 130
        With ThisWorkbook.Sheets(i)
            On Error Resume Next
            Columns[COLOR=#ff0000](1)[/COLOR].SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
            On Error GoTo 0
        End With
    Next i

End Sub
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Oops, slight typo, it should be
Code:
Sub test()

    Dim i As Long
    
    Application.ScreenUpdating = False
    
    For i = 66 To 130
        With ThisWorkbook.Sheets(i)
            On Error Resume Next
            Columns[COLOR=#ff0000](1)[/COLOR].SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
            On Error GoTo 0
        End With
    Next i

End Sub

This works now, but only on the sheet i have open when I run it.
 
Upvote 0
Apologies, it should be
Code:
Sub test()

    Dim i As Long
    
    Application.ScreenUpdating = False
    
    For i = 66 To 130
        With ThisWorkbook.Sheets(i)
            On Error Resume Next
            [COLOR=#ff0000].[/COLOR]Columns(1).SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
            On Error GoTo 0
        End With
    Next i

End Sub
 
Upvote 0
Apologies, it should be
Code:
Sub test()

    Dim i As Long
    
    Application.ScreenUpdating = False
    
    For i = 66 To 130
        With ThisWorkbook.Sheets(i)
            On Error Resume Next
            [COLOR=#ff0000].[/COLOR]Columns(1).SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
            On Error GoTo 0
        End With
    Next i

End Sub

NAILED IT!! And it runs really quick too!! :rofl:
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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