macro, filter criteria2 = array for date column

ann t long

New Member
Joined
Mar 27, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
a macro reads the filtering selected by the user of an excel data file. When the user selects from a date column, using the tree list to select years, I can record a macro that simulates what has been selected as:
ActiveSheet.Range("$A$3:$T$179896").AutoFilter Field:=4, Operator:= _
xlFilterValues, Criteria2:=Array(0, "3/20/2020", 0, "12/31/2019", 0, "12/31/2018")
I understand that the zero indicates to use the "year" portion of the date, while generating the filter. However, I am having trouble reading the values that are in the array.
my goal is to regurgitate the selected filter to the user and incorporate it into charts that result from further macro actions.
*statements between asterisks fail*
using:
dim afilt as filter
set afilt = activesheet.autofilter.filters(4)
dim varCri as variant
dim VCri(6) as variant
*varCri = afilt.criteria2*
*VCri = afilt.criteria2*
*msgbox afilt.criteria2(1)*
*msgbox afilt.criteria2(2)*
*msgbox afilt.criteria2(1,1)*
and the filter is "on" and the operator is 7/xlfiltervalues
Thank you for the help.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I'm attempting the same and having trouble. Did you every figure out the proper method?
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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