Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Check Auto Filter - if on, turn off before running macro

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Check Auto Filter - if on, turn off before running macro

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" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Check Auto Filter - if on, turn off before running macro

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" wrote in message
...
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


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Check Auto Filter - if on, turn off before running macro

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" wrote in message
...
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


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Check Auto Filter - if on, turn off before running macro

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" wrote in message
...
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" wrote in message
...
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

.


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
How do I turn on Auto Filter?? It is grayed out. Ray Excel Discussion (Misc queries) 4 March 18th 09 07:02 PM
Turn off a filter before running a macro Arno Excel Programming 5 September 26th 08 09:46 AM
Macro to allow auto filter after running password protect Roady Excel Discussion (Misc queries) 1 July 17th 08 06:34 PM
Auto filter multiple selection turn off Daniel Excel Discussion (Misc queries) 0 May 7th 08 02:58 PM
excel: how to turn auto-filter on? Pedro Centeno Excel Worksheet Functions 0 December 31st 04 10:41 AM


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

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

About Us

"It's about Microsoft Excel"