Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Displaying AutoFilter criteria


Dear all,

I am using the below function to show the filter value. It works wel
for the first time filter. However, when I change the filter value, th
result of this function is unchanged until I go to the cell containin
this function and press F2 and then Enter, the result of this functio
is changed.

Function FilterCriteria(Rng As Range) As String
'By Stephen Bullen
Dim Filter As String
Filter = ""
On Error GoTo Finish
With Rng.Parent.AutoFilter
If Intersect(Rng, .Range) Is Nothing Then GoTo Finish
With .Filters(Rng.Column - .Range.Column + 1)
If Not .On Then GoTo Finish
Filter = .Criteria1
Select Case .Operator
Case xlAnd
Filter = Filter & " AND " & .Criteria2
Case xlOr
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish:
FilterCriteria = Filter
End Function

Is there any way that makes this function work without pressing F2 an
Enter when the value of filter is changed.

Thanks a lot!

Na

--
lehaina
-----------------------------------------------------------------------
lehainam's Profile: http://www.excelforum.com/member.php...fo&userid=1861
View this thread: http://www.excelforum.com/showthread.php?threadid=47198

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Displaying AutoFilter criteria

Tom Ogilvy has suggested this:

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

Should trigger it to update. Change B5:B200 to reflect the address of a
column in the filtered database.



lehainam wrote:

Dear all,

I am using the below function to show the filter value. It works well
for the first time filter. However, when I change the filter value, the
result of this function is unchanged until I go to the cell containing
this function and press F2 and then Enter, the result of this function
is changed.

Function FilterCriteria(Rng As Range) As String
'By Stephen Bullen
Dim Filter As String
Filter = ""
On Error GoTo Finish
With Rng.Parent.AutoFilter
If Intersect(Rng, .Range) Is Nothing Then GoTo Finish
With .Filters(Rng.Column - .Range.Column + 1)
If Not .On Then GoTo Finish
Filter = .Criteria1
Select Case .Operator
Case xlAnd
Filter = Filter & " AND " & .Criteria2
Case xlOr
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish:
FilterCriteria = Filter
End Function

Is there any way that makes this function work without pressing F2 and
Enter when the value of filter is changed.

Thanks a lot!

Nam

--
lehainam
------------------------------------------------------------------------
lehainam's Profile: http://www.excelforum.com/member.php...o&userid=18615
View this thread: http://www.excelforum.com/showthread...hreadid=471985


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Displaying AutoFilter criteria

Dave, are suggesting adding this code to the function or using this to
call the function? TIA

Greg

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Displaying AutoFilter criteria

The code wouldn't change.

But the formula in the cell would. (So I guess #2.)

GregR wrote:

Dave, are suggesting adding this code to the function or using this to
call the function? TIA

Greg


--

Dave Peterson
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
Displaying multiple non-adjacent cells with 1 criteria Roel Broos Excel Worksheet Functions 3 May 7th 09 10:38 AM
Displaying date in filter criteria Robert Mark Bram Excel Discussion (Misc queries) 2 January 16th 09 10:55 PM
Displaying autofilter criteria [email protected] Excel Worksheet Functions 0 February 25th 05 09:41 PM
AutoFilter Criteria VBA EstherJ Excel Programming 2 August 20th 04 12:54 PM
VBA Autofilter Criteria Brandon[_5_] Excel Programming 1 November 7th 03 12:40 PM


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