Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Obtaining AutoFilter Filter Settings Automatically
I got ya... check to see if it the filter is on, before trying to read the
criteria. got it. thanks. "OssieMac" wrote: Hello Mark, Hopefully the following example will point you in the right direction. Sub TestForFilter() 'Note Criteria2 is if custom filter Between etc is used 'and .Operatior tests for this Dim i As Long i = 2 'No of col/filter being tested With ActiveSheet 'Test if Autofilter invoked If .AutoFilterMode Then 'Test if an actual filter is set If .FilterMode Then With .AutoFilter.Filters(i) If .On Then MsgBox "Filter " & i & " is " & .Criteria1 If .Operator Then MsgBox "Filter " & i & " is " & .Criteria2 Else MsgBox "No Criteria 2 for Filter " & i End If Else MsgBox "Filter " & i & " is Off" End If End With Else MsgBox "No Filters have been set." End If Else MsgBox "Autofilter is not turned on." End If End With -- Regards, OssieMac "mark" wrote: Hello. I have a worksheet with an autofilter set. The AutoFilter has 69 columns in it. I can obtain that number like this: Dim flt As AutoFilter Set flt = wsBOM.AutoFilter MsgBox flt.Filters.count What I want to know is if one of two specific columns are filtered to =TRUE I can find that, if they are, by using: MsgBox flt.Filters(Range(cnLTMFGCPOrChange).Column).Crite ria1 . If the filter is set, that returns "=TRUE" But, if the filter is not set to anything, I get an error message box which has the title Microsoft Visual Basic, has a red circle x on the left, and says 400. I tried putting On Error Resume Next before it, but it still gives me the error message box. Can someone help me with how to return or pass by in code when a filter is not set? Basically, the normal condition is that one of two filters will be set. I need to be able to trap which one it was, and hold that information to re-apply it at the end. Thanks. Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
AutoFilter settings in shared workbook | Excel Worksheet Functions | |||
AutoFilter settings in shared workbook | Excel Worksheet Functions | |||
saving autofiltercustom filter settings | Excel Worksheet Functions | |||
Autofilter - Remember settings | Excel Programming | |||
Printing auto-filter settings | Excel Worksheet Functions |