VBA dynamically exclude value in filter

tgmvba

New Member
Joined
Jul 13, 2019
Messages
6
I was wondering if anybody can tell me how to exclude a specific value from a filter after I run my macro. I have the code at the end so it runs last however I am needing to always exclude 0 and #N/A from the output. I cannot tell it what values to include because they change with every run of the macro. So I can only tell it what to filter out. Currently the code I am running is:

Sheets("QuickBase Import").Range("$A$3:$T$1131").AutoFilter Field:=20, Criteria1:= _
"<>0"
Sheets("QuickBase Import").Range("$A$3:$T$1131").AutoFilter Field:=3, Criteria1:= _
"<>#N/A"

However the issue is that the filter will filter out values other than these two which is not ideal. Thanks
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Could you deal with the 0 and the #NA after the macro but before the filter, something like this perhaps for the 0 in column T...

Code:
Dim rng As Range, i As Long
 Set rng = Range("T3:T1131")
 For i = 1 To rng.Cells.Count
     If rng.Cells(i) = 0 Then rng.Cells(i) = ""
 Next
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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