VBA Code to Select Filter Variables

kentster

New Member
Joined
Nov 22, 2016
Messages
28
Hi,

I have this code recorded from Excel 2013:

Code:
 ActiveSheet.Range("$A$5:$BY$922").AutoFilter Field:=31, Criteria1:=Array("0"), Operator:=xlFilterValues, Criteria2:=Array(0, "1/0/1900")

[end code]

It errors our if one of the variables is missing.  I can't have it do that.

I need it to capture either 0, 1/0/1900, or both.  The worst case is if none of them exist then is it feasible to use On Error GoTo Practice: at the beginning of the code?  And then under Practice: I would just have the same code but different variables....

I am doing this for 7 different columns and each column has the same criteria.  Once I get the first niled down, it should be a piece of cake for the others as I just change the "Field:=" value to match the column and the variables and the "On Error GoTo xxxxxx:"

Thanks again
Kent
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
FYI - I went a different route and this is no longer needed. I couldn't find a way to delete the original post.
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,229
Members
448,879
Latest member
VanGirl

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