Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Reset AutoFilter in code

Hi

I know how to remove AutoFilter.
Worksheets("Absence").AutoFilterMode = False

But how can I leave the autofilter in place just removing any applied filter?
Some thing like AutoFilter.reset !

Thanks

Brian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Reset AutoFilter in code

Option Explicit
Sub SetAutoFilter()
Dim target As Range
Set target = Range("A1:C1")
FilterA target
'turn filter OFF
target.AutoFilter
'TURN FILTER ON
target.AutoFilter
End Sub
Sub FilterA(target As Range)
' turns filter ON with a filter
target.AutoFilter Field:=1, Criteria1:="=*1", Operator:=xlAnd
End Sub

"Brian Bermingham" wrote in
message ...
Hi

I know how to remove AutoFilter.
Worksheets("Absence").AutoFilterMode = False

But how can I leave the autofilter in place just removing any applied
filter?
Some thing like AutoFilter.reset !

Thanks

Brian


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Reset AutoFilter in code

Thanks Patrick
I got that to work.
It seems a bit complex for what apears to be a simple operation.
Is there not a simple command to reset autofilter?

Thanks

Brian

"Patrick Molloy" wrote:

Option Explicit
Sub SetAutoFilter()
Dim target As Range
Set target = Range("A1:C1")
FilterA target
'turn filter OFF
target.AutoFilter
'TURN FILTER ON
target.AutoFilter
End Sub
Sub FilterA(target As Range)
' turns filter ON with a filter
target.AutoFilter Field:=1, Criteria1:="=*1", Operator:=xlAnd
End Sub

"Brian Bermingham" wrote in
message ...
Hi

I know how to remove AutoFilter.
Worksheets("Absence").AutoFilterMode = False

But how can I leave the autofilter in place just removing any applied
filter?
Some thing like AutoFilter.reset !

Thanks

Brian



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Reset AutoFilter in code

it was a demo

you need two lines of code
target.AutoFilter
target.AutoFilter

the first turns off/on and the second reverses it

"Brian Bermingham" wrote in
message ...
Thanks Patrick
I got that to work.
It seems a bit complex for what apears to be a simple operation.
Is there not a simple command to reset autofilter?

Thanks

Brian

"Patrick Molloy" wrote:

Option Explicit
Sub SetAutoFilter()
Dim target As Range
Set target = Range("A1:C1")
FilterA target
'turn filter OFF
target.AutoFilter
'TURN FILTER ON
target.AutoFilter
End Sub
Sub FilterA(target As Range)
' turns filter ON with a filter
target.AutoFilter Field:=1, Criteria1:="=*1", Operator:=xlAnd
End Sub

"Brian Bermingham" wrote in
message ...
Hi

I know how to remove AutoFilter.
Worksheets("Absence").AutoFilterMode = False

But how can I leave the autofilter in place just removing any applied
filter?
Some thing like AutoFilter.reset !

Thanks

Brian



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Reset AutoFilter in code

Thanks again Patrick

I now have below which does exactly what I was looking for.

Dim target As Range
Set target = Range("A1:AN1")
If ActiveSheet.AutoFilterMode Then
'turn filter OFF if already on
target.AutoFilter
'then TURN FILTER ON to reset
target.AutoFilter
Else
'turn filter On if already off
target.AutoFilter
End If


"Patrick Molloy" wrote:

it was a demo

you need two lines of code
target.AutoFilter
target.AutoFilter

the first turns off/on and the second reverses it

"Brian Bermingham" wrote in
message ...
Thanks Patrick
I got that to work.
It seems a bit complex for what apears to be a simple operation.
Is there not a simple command to reset autofilter?

Thanks

Brian

"Patrick Molloy" wrote:

Option Explicit
Sub SetAutoFilter()
Dim target As Range
Set target = Range("A1:C1")
FilterA target
'turn filter OFF
target.AutoFilter
'TURN FILTER ON
target.AutoFilter
End Sub
Sub FilterA(target As Range)
' turns filter ON with a filter
target.AutoFilter Field:=1, Criteria1:="=*1", Operator:=xlAnd
End Sub

"Brian Bermingham" wrote in
message ...
Hi

I know how to remove AutoFilter.
Worksheets("Absence").AutoFilterMode = False

But how can I leave the autofilter in place just removing any applied
filter?
Some thing like AutoFilter.reset !

Thanks

Brian





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Reset AutoFilter in code

we appreciate the feedback. many thanks

"Brian Bermingham" wrote in
message ...
Thanks again Patrick

I now have below which does exactly what I was looking for.

Dim target As Range
Set target = Range("A1:AN1")
If ActiveSheet.AutoFilterMode Then
'turn filter OFF if already on
target.AutoFilter
'then TURN FILTER ON to reset
target.AutoFilter
Else
'turn filter On if already off
target.AutoFilter
End If


"Patrick Molloy" wrote:

it was a demo

you need two lines of code
target.AutoFilter
target.AutoFilter

the first turns off/on and the second reverses it

"Brian Bermingham" wrote in
message ...
Thanks Patrick
I got that to work.
It seems a bit complex for what apears to be a simple operation.
Is there not a simple command to reset autofilter?

Thanks

Brian

"Patrick Molloy" wrote:

Option Explicit
Sub SetAutoFilter()
Dim target As Range
Set target = Range("A1:C1")
FilterA target
'turn filter OFF
target.AutoFilter
'TURN FILTER ON
target.AutoFilter
End Sub
Sub FilterA(target As Range)
' turns filter ON with a filter
target.AutoFilter Field:=1, Criteria1:="=*1", Operator:=xlAnd
End Sub

"Brian Bermingham" wrote
in
message ...
Hi

I know how to remove AutoFilter.
Worksheets("Absence").AutoFilterMode = False

But how can I leave the autofilter in place just removing any
applied
filter?
Some thing like AutoFilter.reset !

Thanks

Brian



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Reset AutoFilter in code

But how can I leave the autofilter in place just removing any applied
filter? Some thing like AutoFilter.reset !


One simple quick line :-)

ActiveSheet.ShowAllData

That's it :-)


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Reset AutoFilter in code

Thanks Charlotte

It's always good to know more than one way to do things.

Brian

"Charlotte E" wrote:

But how can I leave the autofilter in place just removing any applied
filter? Some thing like AutoFilter.reset !


One simple quick line :-)

ActiveSheet.ShowAllData

That's it :-)



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
Workbook Reset AutoFilter to ShowAll David J[_3_] Excel Programming 1 November 29th 07 02:31 AM
Reset VB Code Not Working on Close Jane Excel Programming 6 April 10th 06 05:29 PM
Master reset code bug - stumped again peter.thompson[_28_] Excel Programming 1 January 7th 06 07:38 AM
Master reset code -stumped peter.thompson[_24_] Excel Programming 6 January 7th 06 01:35 AM
Autofilter reset button Cheese Excel Discussion (Misc queries) 6 July 9th 05 06:39 PM


All times are GMT +1. The time now is 12:08 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"