code for auto filters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi...

I'm stuck. I'm after some code that will allow a macro button to do the
following...

1. reset all auto filters to standing position (all unfiltered)
2. then filter range a1:a100 for top 10 values without a dialog box popping
up.

It all needs to be easy and intuitive, push of a button feel without the
user thinking about anything.

Thanks...you're my only hope!

Gordon.
 
Hi Gordon

Try
Sub Setfilter()

Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10",
Operator:=xlTop10Items

End Sub
 
Hi

sub FilterIt()
'Remove any filter present on the Range
With ActiveSheet
On Error Resume Next 'required if Advanced filter was used
.ShowAllData
On Error GoTo 0
.AutoFilterMode = False 'Removes drop down arrows
'do the filter
.Range("A1:A100).AutoFilter Field:=1,
Criteria1:=Criteria1:="10",

Operator:=xlTop10Items
End with
End Sub

regards
Paul
 

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

Back
Top