Filter out #DIV/0! from column | Macro

gomes123

New Member
Joined
Jun 16, 2021
Messages
39
Office Version
  1. 2007
Platform
  1. Windows
I've got a table, and in Column J, starting from J3 going downwards, I'd like to filter out all the values which are #DIV/0!

I tried recording a macro and this is what came up below, but the end of the table (J1050) sometimes changes (could be more or less), and also it seems to be including all the values in the table, instead of filtering out #DIV/0!

Just for reference, the cell value in J3 going downwards is
Excel Formula:
=H3/D3

How would I adjust the macro? Thanks!

VBA Code:
Sub Macro1()


    ActiveSheet.Range("$A$2:$L$1050").AutoFilter Field:=10, Criteria1:=Array( _
        "0.01", "0.10", "0.11", "0.12", "0.14", "0.16", "0.20", "0.22", "0.24", "0.28", "0.30", _
        "0.31", "0.33", "0.39", "0.40", "0.42", "0.47", "0.50", "0.52", "0.53", "0.54", "0.55", _
        "0.65", "0.70", "0.72", "1.26", "1.43", "1.60", "1.61", "1.73", "1.77", "1.89", "1.91", _
        "1.96", "10.06", "11.36", "15.76", "2.00", "2.04", "2.13", "2.25", "2.48", "2.84", "3.54" _
        , "3.64", "30.17", "33.65", "4.16", "5.29", "5.42", "5.81", "6.21", "6.54", "7.38", "8.39" _
        ), Operator:=xlFilterValues
End Sub
 

Attachments

  • DIV.jpg
    DIV.jpg
    15.3 KB · Views: 5
Try....


VBA Code:
With ActiveSheet
  .Range("$A$2:L" & .Cells(Rows.Count, "A").End(xlUp).Row).AutoFilter 10, "<>#DIV/0!"
End With
 
Last edited:
Upvote 1
Solution

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