Thread: toolbar button
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier Roger Govier is offline
external usenet poster
 
Posts: 2,886
Default toolbar button

Hi Dennis

I got fed up with this being a one way operation also.
I added this macro to my Personal.xls

Sub AutoFiltOnOff()

Dim actCell As Range
Set actCell = ActiveCell
Application.ScreenUpdating = False
On Error Resume Next
Rows(ActiveCell.Row).Select
Selection.AutoFilter
actCell.Select
On Error GoTo 0
Application.ScreenUpdating = True

End Sub

Then whilst in Customise mode on the Toolbar, utilising the same icon
for the Autofilter,
right clickAssign MacroPersonal.xls!AutoFiltOnOff

The on error resume next is in case you click the button on a row with
no data, which would cause Autofilter to throw an error.
Setting actCell at the beginning, and selecting it at the end, prevents
an entire row selection, if the Resume Next has been invoked.

This quite happily toggles the Autofilter on and off for me.
--
Regards

Roger Govier


"Dennis S." wrote in message
...
I've added a button on the toolbar to turn on Autofilter. How can I
add
another button to turn Autofilter off?