ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autofilter help (https://www.excelbanter.com/excel-programming/375654-autofilter-help.html)

Gary Keramidas

autofilter help
 
how do i tell if an autofilter is applied so i can reset it when the file is
saved?

--


Gary




Bob Phillips

autofilter help
 
If Worksheets("Sheet1").AutoFilterMode Then
isOn = "On"
Else
isOn = "Off"
End If
MsgBox "AutoFilterMode is " & isOn

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
how do i tell if an autofilter is applied so i can reset it when the file

is
saved?

--


Gary






Dave Peterson

autofilter help
 
You may want to reset the autofilter when the workbook is opened--not saved. (I
save lots of times and would hate to have my filtering change each time I save.

One way is to ignore any error that may occur:

Option Explicit
Sub auto_open()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ThisWorkbook.Worksheets
wks.ShowAllData
Next wks
On Error GoTo 0
End Sub

Another way is to check to see if things need to be reset first:

Option Explicit
Sub auto_open()
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
If wks.AutoFilterMode Then
If wks.FilterMode Then
wks.ShowAllData
End If
End If
Next wks
End Sub

Gary Keramidas wrote:

how do i tell if an autofilter is applied so i can reset it when the file is
saved?

--

Gary


--

Dave Peterson

Gary Keramidas

autofilter help
 
thanks for the idea, i'll keep it mind

--


Gary


"Dave Peterson" wrote in message
...
You may want to reset the autofilter when the workbook is opened--not saved.
(I
save lots of times and would hate to have my filtering change each time I
save.

One way is to ignore any error that may occur:

Option Explicit
Sub auto_open()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ThisWorkbook.Worksheets
wks.ShowAllData
Next wks
On Error GoTo 0
End Sub

Another way is to check to see if things need to be reset first:

Option Explicit
Sub auto_open()
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
If wks.AutoFilterMode Then
If wks.FilterMode Then
wks.ShowAllData
End If
End If
Next wks
End Sub

Gary Keramidas wrote:

how do i tell if an autofilter is applied so i can reset it when the file is
saved?

--

Gary


--

Dave Peterson




Gary Keramidas

autofilter help
 
thanks, bob, i guess it was pretty simple

--


Gary


"Bob Phillips" wrote in message
...
If Worksheets("Sheet1").AutoFilterMode Then
isOn = "On"
Else
isOn = "Off"
End If
MsgBox "AutoFilterMode is " & isOn

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
how do i tell if an autofilter is applied so i can reset it when the file

is
saved?

--


Gary









All times are GMT +1. The time now is 10:38 AM.

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