I have a part of a macro that stores the autofilter settings before clearing the filter, so it can reapply them later. The code is as follows:
Dim FilterArray()
I've amended your code and it runs now well also with dates in my Excel 2013:
' .Criteria1/2 are read as strings with local decimal separator
' but for re-setting Criteria1/2 should be in American format ...
' so replace local decimal separator by dot - this seems to apply also for dates,
' because dates are also transformed internally to decimal numbers
FilterArray(f, 1) = Replace(.Criteria1, Application.International(xlDecimalSeparator), ".")
(similar for .Criteria2)
Regarding your secondary question: see code example in this post: In Excel VBA, how do I save / restore a user-defined filter?
I found out, to enable filter Date in Array.
Below setting must be disable (Enable by default)
ActiveWindow.AutoFilterDateGrouping = False
Note, this solution below is true of Excel 2010, I cannot find information on Excel 2013, but it is possible the same problem exists.
If you record a macro while running an auto date filter, you will notice the values are stored in the Criteria2 parameter, and Criteria1 is not used:
Range.AutoFilter Field:=2, Operator:=xlFilterValues, Criteria2:=Array(2, "8/10/2015", 2, "8/20/2015")
Trying to access the Criteria2 parameter from VBA causes an "Application-defined or object-defined error".
At the time of writing this answer, the only way I know of saving this autofilter information is by reading the XML data inside the xlsx file. Working code here:
Get Date Autofilter in Excel VBA