Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Showing criteria in custom filter

I would like to show in a cell the criteria entered into a custom filter of
data for example, if the custom criteria was set as = 3000 then either
enter 3000 in a cell or the text "greater than or equal to 3000"

Is this possible within a worksheet function? any examples would be most
welcome.

Thanks, Rob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Showing criteria in custom filter

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

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
I would like to show in a cell the criteria entered into a custom filter

of
data for example, if the custom criteria was set as = 3000 then either
enter 3000 in a cell or the text "greater than or equal to 3000"

Is this possible within a worksheet function? any examples would be most
welcome.

Thanks, Rob




  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Showing criteria in custom filter

This is just brilliant, thanks Bob and of course Tom for creating the piece
of work.

Regards, Rob
"Bob Phillips" wrote in message
...
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

RP
(remove nothere from the email address if mailing direct)


"Rob" wrote in message
...
I would like to show in a cell the criteria entered into a custom filter

of
data for example, if the custom criteria was set as = 3000 then either
enter 3000 in a cell or the text "greater than or equal to 3000"

Is this possible within a worksheet function? any examples would be most
welcome.

Thanks, Rob






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
Macro/ custom filter, criteria="abc" or blank CousinExcel Excel Discussion (Misc queries) 1 February 17th 10 12:04 PM
Auto filter custom filter stevefromnaki Excel Worksheet Functions 2 December 30th 09 06:23 AM
Getpivotdata....showing filter Tami Excel Worksheet Functions 0 December 10th 09 09:22 PM
Showing custom toolbars on one W/S only JRD Excel Discussion (Misc queries) 3 December 1st 05 05:03 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 12:40 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"