Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Inserting an option button in Word
 
Posts: n/a
Default Input filtered item in a separate cell

Anyone know how I can filter a list by a variable in a list and have cell A2
always show the latest variable the list is filtered by. The list would start
on say Row 4 so e.g Heading is Product, this column filtered to show the word
Health. I want this to automatically also appear in Cell A2. using Excel 2003.

Thanks in advance.
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

From Tom Ogilvy:

*******************************
Here is a user defined function that will display the criteria in a cell:

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

=ShowFilter(B5)&left(Subtotal(*9,B5:B200),0)

would show the filter for column 2

I usually put these functions in cells above the filter.
************************************************** ****
Note that the Subtotal function is used to re-calc the cell when the filter is changed - that won't
ahppen if you just us the ShowFilter function.

HTH,
Bernie
MS Excel MVP


" Inserting an option button in Word" soft.com
wrote in message ...
Anyone know how I can filter a list by a variable in a list and have cell A2
always show the latest variable the list is filtered by. The list would start
on say Row 4 so e.g Heading is Product, this column filtered to show the word
Health. I want this to automatically also appear in Cell A2. using Excel 2003.

Thanks in advance.



  #3   Report Post  
Inserting an option button in Word
 
Posts: n/a
Default

Thanks Bernie,

I'll try it now.

"Bernie Deitrick" wrote:

From Tom Ogilvy:

*******************************
Here is a user defined function that will display the criteria in a cell:

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

=ShowFilter(B5)&left(Subtotal(Â*9,B5:B200),0)

would show the filter for column 2

I usually put these functions in cells above the filter.
************************************************** ****
Note that the Subtotal function is used to re-calc the cell when the filter is changed - that won't
ahppen if you just us the ShowFilter function.

HTH,
Bernie
MS Excel MVP


" Inserting an option button in Word" soft.com
wrote in message ...
Anyone know how I can filter a list by a variable in a list and have cell A2
always show the latest variable the list is filtered by. The list would start
on say Row 4 so e.g Heading is Product, this column filtered to show the word
Health. I want this to automatically also appear in Cell A2. using Excel 2003.

Thanks in advance.




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
Separate last word in cell with more than 2 words? Pat Mayton Excel Worksheet Functions 2 March 24th 05 03:37 PM
what is the format for an input cell? Pumaman Excel Discussion (Misc queries) 2 February 8th 05 05:05 AM
Combined date time cell to separate date & time components Mark Ada Excel Discussion (Misc queries) 1 December 2nd 04 02:48 AM
Combined date time cell to separate date & time components Mark Ada Excel Discussion (Misc queries) 1 December 2nd 04 12:07 AM
Combined date time cell to separate date & time components Mark Ada Excel Discussion (Misc queries) 1 December 2nd 04 12:07 AM


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