I'm trying to save an autofilter, to then do some things on my worksheets and re-apply the filter.
Following this topic : In Excel VBA, how do I save / restore a user-defined filter? ; it was about to work. Then I tried to filter on a date column, and it doesn't works --> It gives me the following error :
I've looking for hours on internet to found a solution, like the following post: Excel VBA Saving autofilter settings with dates; but I can't fix this problem...
I was also thinking about convert the entire column in number format, but it doesn't works as the hide cells are not converted and the filter doesn't convert the value in the filter list.
It seems like dates are not valid values to give for a Criteria1
.. could it be?
Here is my code:
With myCurrentWorkbook.Worksheets(my_Of_To_Produce_Sheet).AutoFilter
With .Filters
ReDim filterArray(1 To .Count, 1 To 3)
For f = 1 To .Count
With .Item(f)
If .On Then
filterArray(f, 1) = .Criteria1 'it's on this line that it doesn't work
'I tried this solution found on internet
'filterArray(f, 1) = Replace(.Criteria1, Application.International(xlDecimalSeparator), ".")
If .Operator Then
filterArray(f, 2) = .Operator
If .Operator = xlAnd Or .Operator = xlOr Then
filterArray(f, 3) = .Criteria2
End If
End If
End If
End With
Next f
End With
End With