I have also posted this at on old thread - http://www.mrexcel.com/forum/showthread.php?p=2265955
I know this is an old thread but it is the only one I could find that is close to my problem.
Does anyone know if it is possible to discover the criteria used by the user to save and restore the state of an autofilter if Operator:= xlFilterValues?
When I attempt to record a macro to create an autofilter as follows:
start snippet:
Sub Macro2()
'
' Macro2 Macro
'
'
Range("D3").Select
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=5, Criteria1:= _
Array("1 - Identify", "2 - Qualified/Contacted", "6 - Close"), Operator:= _
xlFilterValues
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=6, Operator:= _
xlFilterValues, Criteria2:=Array(0, "9/30/2010", 1, "4/28/2009", 1, "5/1/2009", 1, _
"10/26/2009", 2, "12/18/2009", 2, "12/31/2009")
End Sub
end snippet:
I can (of course) replay this macro to obtain the same autofilter result as the first time I used the autofilter (to create the recorded macro). However, if I attempt to use the saveautofilter and restoreautofilter functionality as presented by "Peter SSs" in this thread (I have used similar functionality successfully in Excel 2003 for a few years), when I try to access the value of Criteria1 (and Criteria2 if it exists), I receive error 1004 (the wonderfully generic "application-defined or object-defined error").
As expected, attempting to read the values stored in Criteria1 and Criteria2 using the watch window is impossible too. For now, I am checking if the .Operator value = xlFilterValues and, if it is, do nothing.
If anyone has any method to discover or read the filter values referenced via the complex filter that exists if .Operator = xlFilterValues, I would love to hear about it.
Thanks,
Steve
I know this is an old thread but it is the only one I could find that is close to my problem.
Does anyone know if it is possible to discover the criteria used by the user to save and restore the state of an autofilter if Operator:= xlFilterValues?
When I attempt to record a macro to create an autofilter as follows:
start snippet:
Sub Macro2()
'
' Macro2 Macro
'
'
Range("D3").Select
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=5, Criteria1:= _
Array("1 - Identify", "2 - Qualified/Contacted", "6 - Close"), Operator:= _
xlFilterValues
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=6, Operator:= _
xlFilterValues, Criteria2:=Array(0, "9/30/2010", 1, "4/28/2009", 1, "5/1/2009", 1, _
"10/26/2009", 2, "12/18/2009", 2, "12/31/2009")
End Sub
end snippet:
I can (of course) replay this macro to obtain the same autofilter result as the first time I used the autofilter (to create the recorded macro). However, if I attempt to use the saveautofilter and restoreautofilter functionality as presented by "Peter SSs" in this thread (I have used similar functionality successfully in Excel 2003 for a few years), when I try to access the value of Criteria1 (and Criteria2 if it exists), I receive error 1004 (the wonderfully generic "application-defined or object-defined error").
As expected, attempting to read the values stored in Criteria1 and Criteria2 using the watch window is impossible too. For now, I am checking if the .Operator value = xlFilterValues and, if it is, do nothing.
If anyone has any method to discover or read the filter values referenced via the complex filter that exists if .Operator = xlFilterValues, I would love to hear about it.
Thanks,
Steve