Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use "OR" in two auto-filters/custom filters? Roady Excel Discussion (Misc queries) 1 May 24th 10 06:11 PM
Auto Filters se7098 Excel Worksheet Functions 2 October 13th 08 11:24 PM
How can I auto-refresh auto-filters when data changes? Mike@MPWco Excel Worksheet Functions 0 July 4th 06 12:50 PM
auto filters chanceygardener Excel Discussion (Misc queries) 5 April 27th 06 05:32 PM
code for auto filters Gordon[_2_] Excel Programming 2 January 20th 06 11:29 AM


All times are GMT +1. The time now is 06:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"