Display filter criteria

hujenx

New Member
Joined
Feb 9, 2009
Messages
25
I have this function to display filtered column criteria in a cell, which works for 2 criteria, but I need to extend to 10 criteria and my VBA's inadequate - can anyone point me in the right direction please?


Function AutoFilter_Criteria(Header As Range) As String

Dim strCri1 As String, strCri2 As String, strCri3 As String




Application.Volatile



With Header.Parent.AutoFilter

With .Filters(Header.Column - .Range.Column + 1)



If Not .On Then Exit Function



strCri1 = .Criteria1



If .Operator = xlOr Then

strCri2 = " , " & .Criteria2



End If



End With

End With



AutoFilter_Criteria = UCase(Header) & ": " & strCri1 & strCri2

End Function
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Thanks for the thought, but the code there only displays one criteria, so no advance - in fact one step back!
 
Upvote 0
Just guessing because I'm not clear exactly what you are dealing with, but here is an example I posted some time ago that returns criteria for several filtered columns. You can see how to amend the code to add more UDFs depending on how many columns, and which columns, you are filtering.

Sorry if this is not related to your situation, again, taking a stab at what you might need:

http://www.mrexcel.com/forum/showthread.php?t=229636
 
Upvote 0
Just guessing because I'm not clear exactly what you are dealing with, but here is an example I posted some time ago that returns criteria for several filtered columns. You can see how to amend the code to add more UDFs depending on how many columns, and which columns, you are filtering.

Sorry if this is not related to your situation, again, taking a stab at what you might need:

http://www.mrexcel.com/forum/showthread.php?t=229636

Thanks.

Your code gives the same result as the one I originally posted - max 2 criteria per column.

I have one column and wish to select up to 10 criteria.

It would look like the code is extensible to that, but I just don't know enough to do that.
 
Upvote 0
Did you ever get to the bottom of this? I'm looking to do the same.

Hi, it's so long ago that I can't remember! I looked back at my main task at that time, but still wasn't enough to really jog the memory. I have a suspicion though that I may have resolved it just with data validation. If you give me a bit of detail n what you're trying to do I'll look at my file again and see if there's anything there that might help - I did manage to make the whole thing function well eventually and it had many filtering aspects.
 
Upvote 0
I managed to kind of do what I wanted. Definitely not perfect. Came at it from another angle.
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top