ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofilter - Toggles OFF ? (https://www.excelbanter.com/excel-programming/369477-autofilter-toggles-off.html)

Jim May

Autofilter - Toggles OFF ?
 
In a worksheet when opened I have a table with auto-filter turned on
(showing the drop-down arrows for each of the 15 fields).

When I run a macro to update the sheet, when complete the auto-filter
Is not applied. I immediately run the macro again, and the auto-filter
Is back -- So obviously with these lines of code this is the natural
occurrence.

.....
With ActiveSheet
.Range("A5").AutoFilter
End With

So I changed the above to:
Thinking the new line would always set the a/f to True,

With ActiveSheet
.Range("A5").AutoFilter
.FilterMode = True
End With

But it doesn't. What must I do to have auto-filter ALWAYS ON
After repeated runs of my macro?

Thanks for any help..



somethinglikeant

Autofilter - Toggles OFF ?
 
Hi Jim,

This will always keep your filter on, columns A to O

Sub AutoFilterOn()
If Sheets("Sheet1").AutoFilterMode = False Then
Range("A1:O1").AutoFilter
End Sub

Replace ("Sheet1") with the naem of your sheet and maybe change the
range to your column headers.

somethinglikeant
http://www.excel-ant.co.uk


Jim May

Autofilter - Toggles OFF ?
 
Somethinglikeant

Thanks so much, works great..
Appreciate the help
Jim

"somethinglikeant" wrote in message
oups.com:

Hi Jim,

This will always keep your filter on, columns A to O

Sub AutoFilterOn()
If Sheets("Sheet1").AutoFilterMode = False Then
Range("A1:O1").AutoFilter
End Sub

Replace ("Sheet1") with the naem of your sheet and maybe change the
range to your column headers.

somethinglikeant
http://www.excel-ant.co.uk




All times are GMT +1. The time now is 12:41 PM.

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