Filter out (hide) "0" value when other values are dynamic

usermrex

New Member
Joined
Feb 6, 2012
Messages
14
Hi,

Column A has values that are dynamic references that change based on other inputs. Some rows will often have no data, so the value for these in column A is "0".

I need a macro that will filter OUT all the rows with "0".

The problem is that when I record my macro, it actually filters IN the other values, which are specific to when the macro is first recorded. So when the values change, none are found because it is looking for the ones originally specified in the macro.

ActiveSheet.Range("$A$8:$AL$101").AutoFilter Field:=1, Criteria1:=Array( _
"Marker 001", "Marker 002", "Marker 003", "Marker 004", "Marker 005"), Operator:= _
xlFilterValues


The "Markers" will have different names as the spreadsheet is used.

Can this be fixed relatively easily? I know some advise against using filters altogether, but this is not an option for me...

Thanks very much,
:) Sara
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Thanks Dermie,

Unfortunately that didn't work. I tried adding "<>0" and again entering ONLY "<>0", but for both I got the message "run-time error '1004': AutoFilter method of Range class failed"

:( Sara
 
Upvote 0
Hi Sara,

Try adding:

ActiveSheet.Range("$A$8:$AL$101").AutoFilter Field:=1, Criteria1:="<>0", _
Operator:=xlAnd

just below the one you have, so it picks it up as the and statement
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,290
Members
449,149
Latest member
mwdbActuary

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