LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Autofilter

Hello I have a sheet which contains a large amount of data, this data is
broken down into different departments; the departments are known by the
first two numbers, so 16000 is department A and 17000 is department B.

For examples sake I have three buttons, one button allows you to view the
sheet with everything unfiltered, one button is just to filter out everything
but 16 and the other to just display 17.

At the moment I'm doing it with the following VBA Code -


Private Sub filterSheet(dep As Integer, sht As String)
Sheets(sht).Select
Columns("A:M").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=" & dep & "0000",
Operator:=xlAnd, Criteria2:="<" & dep + 1 & "0000"
End Sub

This does what I want it to, but the problem comes with the line
Selection.AutoFilter
Because the button that takes me to the sheet to view ALL the departments,
doesn't use an Autofilter, yet the BACK button on this sheet uses the line
Selection.Autofilter to disable the autofilter and if it's not been set then
I get a problem where it becomes disabled when it should be active.

I'm just wondering if there is a way to specify Autofilter = False or
something like that?

I do hope that made some sense, as I think it gets quite muddled towards the
middle :)

Thanks for any help in advance!





 
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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


All times are GMT +1. The time now is 05:16 AM.

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

About Us

"It's about Microsoft Excel"