Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoFilter settings in shared workbook [email protected] Excel Worksheet Functions 1 March 22nd 07 01:59 PM
AutoFilter settings in shared workbook Jill Excel Worksheet Functions 2 March 21st 07 05:00 PM
saving autofiltercustom filter settings Edwin199976 Excel Worksheet Functions 2 December 13th 06 06:52 PM
Autofilter - Remember settings Paul Brown[_2_] Excel Programming 2 January 27th 06 11:52 PM
Printing auto-filter settings Scott buckwalter Excel Worksheet Functions 0 August 10th 05 11:07 PM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"