clean data, remove rows of #N/A and zeros

egoburnswell

New Member
Joined
Sep 2, 2015
Messages
5
Hi, so I have large workbooks that contain many sheets each with many rows of data.
lots of these rows are either entirely #N/As or entirely zero, and I would like to remove these. I have some code that sort of does it:


Code:
Dim ws As Worksheet


Application.ScreenUpdating = False
Application.Calculation = xlcalculateMaual


For Each ws In ActiveWorkbook.WorkSheets


    ws.Activate
    Debug.Print ws.Name
    B = Range("b3").End(xlDown).Row
    
    For i = B To 3 Step -1
    
        If IsError(Range("a" & i).Value) Then
        
            Range("a" & i).EntireRow.Delete
            
        Else
        
            For j = 1 To 16


                If Cells(i, j).Value = 0 Then
                    If j = 16 Then Range("a" & i).EntireRow.Delete
                Else
                    Exit For
                End If
                
            Next j
        
        End If
        
    Next i


Next ws


Application.ScreenUpdating = True
Application.Calculation = xlcalculateAutomatic

However it's very slow and it seems to hang. The "good" bit of the data is mostly numeric, but not entirely, and contains isolated DIV/0 which messes up attempts to sum across rows instead of checking each element.

I tried using Selection.Autofilter with various options, but couldn't get this to work correctly.

Any help would be appreciated. Thanks.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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