ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear autofilters? (https://www.excelbanter.com/excel-programming/351459-clear-autofilters.html)

Rishi Dhupar

Clear autofilters?
 
Hi,

I am filtering my data, based on user input. But I need a way to reset
the filters, here is some example code. Say I filter by one, then
reset the data by using Spreadsheet1.ActiveSheet.ShowAllData then they
try to filter by "2". Problem is that it includes "1" and "2". How
can I fix this?

Thanks

With Me.Spreadsheet1.ActiveWorkbook.ActiveSheet
Set owcAutoFilter = .autoFilter
With owcAutoFilter
With .Filters(1).Criteria
.FilterFunction = ssFilterFunctionInclude
.Add "1"
End With
.Apply
End With
Set owcAutoFilter = Nothing
End With


Rishi Dhupar

Clear autofilters?
 
Just to add to this, I tried to shut the autofilter off and then on
again to clear the filter doesn't seem to work. Using this code

'OFF
Me.Spreadsheet1.ActiveSheet.AutoFilterMode = False
'ON
Me.Spreadsheet1.ActiveSheet.UsedRange.autoFilter


Crowbar via OfficeKB.com

Clear autofilters?
 
If you just want to reset one filter: -

Selection.AutoFilter Field:=1


you will have to change the field number as appropiate

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200601/1

Rishi Dhupar

Clear autofilters?
 
Errr... love it when I figure it out after I post. I was saving my
input in an array and wasn't resetting it.

thanks have a nice day.



All times are GMT +1. The time now is 07:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com