If this is all the OP wants to do, then I would probably do away with the
test and simply always set it to False no matter what its current setting
is...
Sub AutoFilterSetToOff()
ActiveSheet.AutoFilterMode = False
End Sub
--
Rick (MVP - Excel)
"J_Knowles" <(E-Mail Removed)> wrote in message
news:8BF9026A-A92D-426F-877A-(E-Mail Removed)...
> Here's what you need.
>
> Sub AutoFilterSetToOff()
> If ActiveSheet.AutoFilterMode = True Then
> ActiveSheet.AutoFilterMode = False
> End If
> End Sub
>
> HTH
> --
> Data Hog
>
>
> "Munchkin" wrote:
>
>> Can you display the code? I don't know what it is & can't seem to be
>> able to
>> figure it out.
>>
>> "Rick Rothstein" wrote:
>>
>> > You can test the AutoFilterMode property of the worksheet... it will be
>> > True
>> > if the AutoFilter is active and False otherwise. You can set the
>> > property to
>> > False in your code to turn AutoFilter'ing off (but you cannot set the
>> > property to True to turn it back on though).
>> >
>> > --
>> > Rick (MVP - Excel)
>> >
>> >
>> > "Munchkin" <(E-Mail Removed)> wrote in message
>> > news:65530615-7598-4713-9A33-(E-Mail Removed)...
>> > >I can't figure out how to do this. Before my macro runs I want to
>> > >check to
>> > > see if AutoFilter is turned on. If it is I want to turn it off - if
>> > > it
>> > > isn't
>> > > then do nothing.
>> > >
>> > >
>> > >
>> > > Rows("2:4").Select
>> > > Selection.EntireRow.Hidden = False
>> > > Range("A2").Select
>> > > Selection.ClearContents
>> > >
>> > > Range("I2").Select
>> > > 'Application.Run "'NamedInsuredList 2
>> > > 11-2009.xls'!CheckBoxFilter_Click"
>> > > Range("PolicyList").Sort Key1:=Range("A7"), Order1:=xlAscending,
>> > > Header:= _
>> > > xlGuess, OrderCustom:=1, MatchCase:=False,
>> > > Orientation:=xlTopToBottom, _
>> > > DataOption1:=xlSortTextAsNumbers
>> > >
>> > > Range("A2").Select
>> >
>> > .
>> >
|