Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code to control auto filters
I have a column that I need auto filtering to the top ten values in say
column/range A10:A100. I'm looking for code to do this. the code should begin with removing all filters and then re-instating them so they are back to an unfiltered state. I don't want my users touching the filters, but more just touching a macro button to execute the procedure. I asked this question earlier today but the code came up as invalid in red. Any help gratefully received. Gordon |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code to control auto filters
Hello Gordon,
You could use something like this ... Option Explicit Sub FilterTopTen() 'take off autofilter If ActiveSheet.AutoFilterMode = True Then ActiveSheet.Cells.AutoFilter End If 'set new autofilter Range("A10:A100").AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Items ' Range("A10:A100").AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent End Sub You didn't specify if you wanted top 10 items or percent. You have either/or to choose from. Note this assumes the activesheet is the sheet with the range you wish to filter. HTH -- Regards, Zack Barresse, aka firefytr, (GT = TFS FF Zack) To email, remove the NO SPAM. Please keep correspondence to the board, as to benefit others. "Gordon" wrote in message ... I have a column that I need auto filtering to the top ten values in say column/range A10:A100. I'm looking for code to do this. the code should begin with removing all filters and then re-instating them so they are back to an unfiltered state. I don't want my users touching the filters, but more just touching a macro button to execute the procedure. I asked this question earlier today but the code came up as invalid in red. Any help gratefully received. Gordon |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I use "OR" in two auto-filters/custom filters? | Excel Discussion (Misc queries) | |||
Auto Filters | Excel Worksheet Functions | |||
How can I auto-refresh auto-filters when data changes? | Excel Worksheet Functions | |||
auto filters | Excel Discussion (Misc queries) | |||
code for auto filters | Excel Programming |