Deleting Filtered Data

BillTony

Board Regular
Joined
May 3, 2017
Messages
70
I have a worksheet where the dataset will never be the same from day to day.

I'm using filtering and I show only rows that do not equal a #N/A value.

I recorded a macro to delete the non-#N/A rows.

In this particular example, there are 101 rows to delete.

How can I - without arbitrarily tossing in some number like 150,000 as the upper limit - adjust for the exact size of the dataset as it increases or decreases?
Code:
ActiveSheet.Range("$A$1:$ZZ" & Last_Row_ColA).AutoFilter Field:=43, Criteria1:="<>#N/A"
    Rows("2:101").Select
    Selection.Delete shift:=xlUp
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Do you mean something like....

Code:
Sub FilterDel()
    With Range("A1:ZZ" & Range("A" & Rows.Count).End(xlUp).Row)
        .AutoFilter Field:=43, Criteria1:="<>#N/A"

        On Error Resume Next
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
        On Error GoTo 0
        .AutoFilter

    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,776
Messages
6,132,659
Members
449,744
Latest member
kauamarcosms

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