#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Filter Condition

Hi,

I have a spreadsheet that allows inexperienced users do their own analysis
on a large table of data by using filtering and SUBTOTAL().

I would really like to show close the the final results what choice(s), i.e.
the filter condition(s), that have been selected to produce the results.
This will enable them to print out the results and know at a later date what
the figures represent.

Is there any way of determining, by function or VBA, the filter condition of
each column?

Thanks,
Fred
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Filter Condition


Courtesy of Tom Ogilvy

You use it like so

=showfilter(L1)&CHAR(SUBTOTAL(9,L2)*0+32)

The CHAR(SUBTOTAL bit is just to force a recalc if the criteria are changed

Public Function ShowFilter(rng As Range)
Dim filt As Filter
Dim sCrit1 As String
Dim sCrit2 As String
Dim sop As String
Dim lngOp As Long
Dim lngOff As Long
Dim frng As Range
Dim sh As Worksheet

Set sh = rng.Parent
If sh.FilterMode = False Then
ShowFilter = "No Active Filter"
Exit Function
End If
Set frng = sh.AutoFilter.Range

If Intersect(rng.EntireColumn, frng) Is Nothing Then
ShowFilter = CVErr(xlErrRef)
Else
lngOff = rng.Column - frng.Columns(1).Column + 1
If Not sh.AutoFilter.Filters(lngOff).On Then
ShowFilter = "No Conditions"
Else
Set filt = sh.AutoFilter.Filters(lngOff)
On Error Resume Next
sCrit1 = filt.Criteria1
sCrit2 = filt.Criteria2
lngOp = filt.Operator
If lngOp = xlAnd Then
sop = " And "
ElseIf lngOp = xlOr Then
sop = " or "
Else
sop = ""
End If
ShowFilter = sCrit1 & sop & sCrit2
End If
End If
End Function



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Fred Davis" wrote in message
...
Hi,

I have a spreadsheet that allows inexperienced users do their own analysis
on a large table of data by using filtering and SUBTOTAL().

I would really like to show close the the final results what choice(s),
i.e.
the filter condition(s), that have been selected to produce the results.
This will enable them to print out the results and know at a later date
what
the figures represent.

Is there any way of determining, by function or VBA, the filter condition
of
each column?

Thanks,
Fred



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default Filter Condition

Fred;

Why not just use the autofilter. Select a cell in your data and apply the
autofilter. Filter any criteria with the autofilter, except the columns that
you are summing. One cell below the subtotal click sum(). Select the entire
column of data, not the entire column. When you filter the data the sub total
will change automatically.

God Bless

Frank Pytel

"Fred Davis" wrote:

Hi,

I have a spreadsheet that allows inexperienced users do their own analysis
on a large table of data by using filtering and SUBTOTAL().

I would really like to show close the the final results what choice(s), i.e.
the filter condition(s), that have been selected to produce the results.
This will enable them to print out the results and know at a later date what
the figures represent.

Is there any way of determining, by function or VBA, the filter condition of
each column?

Thanks,
Fred

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
Combine an OR condition with an AND condition Will Excel Discussion (Misc queries) 1 April 6th 07 03:52 PM
How do I use advanced filter to filter for blank cells? Monique Excel Discussion (Misc queries) 2 March 21st 06 06:43 PM
Condition 1 overules condition 2? Bultgren Excel Worksheet Functions 2 January 20th 06 12:29 PM
Excel auto filter doesn't recoginize case - won't filter AA from A Mikey Excel Discussion (Misc queries) 1 September 29th 05 08:18 PM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM


All times are GMT +1. The time now is 05:32 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"