Autofilter - Toggles OFF ?

J

Jim May

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..
 
S

somethinglikeant

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top