Autofilter out blanks and 0's

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
569
Office Version
  1. 365
Platform
  1. Windows
I have a larger spreadsheet and I have an autofilter that runs to filter for rows that have a value greater than 0. This works just fine.
I was recently tasked with adding to the autofilter so that it would also filter out blanks and cells that have =0. The formula I have is listed below and everything up to Criteria1 is what I have that worked. I need to have my filter work to do the following:

Filter for values greater than 0
Filter out blanks
Filter out cells that =0

VBA Code:
Sheets("Pricing Sheet").Range("$B$6:$B" & LRow).AutoFilter Field:=1, Criteria1:=">0", Operator:=xlAnd, Criteria2:="<>", Operator:=xlAnd, Criteria3:="<>0"

When I run my code it fails with this error.

Run-time error 1004:

Application-defined or object-defined error

I do not understand why it is failing. Can anyone help me figure out what I need to do to accomplish all three of these filter criteria?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You can only use 2 criteria, but as your 1st criteria already deals with your 3rd criteria, just get rid of the final part of the code.
 
Upvote 0
Fluff,

You are awesome. It works great. I appreciate your help. Thank you so much!!!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,016
Members
449,280
Latest member
Miahr

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