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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I'm attempting the same and having trouble. Did you every figure out the proper method?
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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