Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Which columns AutoFilter is on.

1st the question. If I use Set rng = ActiveSheet.AutoFilter.Range and
then do this rngColumns = rng.Address I can extract the columns from
here with Instr(Left/Right/Mid) or whatever. What I want to know how
to do is a for/next to determine which of these columns has its
individual filter turned on....

What I am ultimately trying to create is an add-in type of thing that a
user can take their spreadsheet and use the autofilter as they normally
do. And then when the want, click a button that will take what ever
filters that are "on" and SELECT DISTINCT or a GROUP BY or something
that will provide unique records for those select filters.

An example using 5 columns:

A B C D E
1 Model Accy_# P/N Supplier Price
2 341 125 213 Guys 1.25
3 341 222 213 Guys 1.25
4 411 574 213 Guys 1.25
5 411 222 444 Bobs 5.75
6 580 574 213 Guys 1.25
7 580 746 444 Bobs 5.75
8 580 222 213 Bobs 1.25
9 580 125 516 Guys 2.25


So in this example if the user selected the filter in column C and
choose 213 they would get all the models and accy_#'s with that - but
if they just have that one filter on and click the button I want to
ignore everything else and make a single row with that P/N on it
without having to go Data/Advanced Filter/Copy to another location,
unique records only...

Or if they selected a supplier (e.g. Guys) and click the button I want
to show only P/N 213 & 516.... I expect this to get harder as I dig
into it, but this is the high level view of what I'm trying to do...

Thanks

-Steve

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Which columns AutoFilter is on.

You could loop through the Filters collection to check which Filter has its
Filter on.

Sub test()
Dim rngFilter As Range

Set rngFilter = Sheet2.AutoFilter.Range

With Sheet2.AutoFilter
For i = 1 To .Filters.Count
If .Filters(i).On Then
MsgBox .Range.Columns(i).Column
MsgBox .Range.Columns(i).Address
End If
Next i
End With

End Sub



" wrote:

1st the question. If I use Set rng = ActiveSheet.AutoFilter.Range and
then do this rngColumns = rng.Address I can extract the columns from
here with Instr(Left/Right/Mid) or whatever. What I want to know how
to do is a for/next to determine which of these columns has its
individual filter turned on....

What I am ultimately trying to create is an add-in type of thing that a
user can take their spreadsheet and use the autofilter as they normally
do. And then when the want, click a button that will take what ever
filters that are "on" and SELECT DISTINCT or a GROUP BY or something
that will provide unique records for those select filters.

An example using 5 columns:

A B C D E
1 Model Accy_# P/N Supplier Price
2 341 125 213 Guys 1.25
3 341 222 213 Guys 1.25
4 411 574 213 Guys 1.25
5 411 222 444 Bobs 5.75
6 580 574 213 Guys 1.25
7 580 746 444 Bobs 5.75
8 580 222 213 Bobs 1.25
9 580 125 516 Guys 2.25


So in this example if the user selected the filter in column C and
choose 213 they would get all the models and accy_#'s with that - but
if they just have that one filter on and click the button I want to
ignore everything else and make a single row with that P/N on it
without having to go Data/Advanced Filter/Copy to another location,
unique records only...

Or if they selected a supplier (e.g. Guys) and click the button I want
to show only P/N 213 & 516.... I expect this to get harder as I dig
into it, but this is the high level view of what I'm trying to do...

Thanks

-Steve


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
autofilter on many columns inquirer Excel Discussion (Misc queries) 3 July 16th 06 04:32 AM
Is there a way I can autofilter columns instead of rows Brian A. Excel Worksheet Functions 0 October 27th 05 03:15 PM
AutoFilter - non adjacent columns Richard Excel Discussion (Misc queries) 4 August 15th 05 12:15 PM
using autofilter to search 2 columns neowok[_11_] Excel Programming 6 February 19th 04 02:40 PM
VBA to set which columns in Autofilter miker1999[_10_] Excel Programming 2 February 15th 04 02:44 AM


All times are GMT +1. The time now is 02:57 PM.

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"