How to Identify the selected text from the dropdown menu of an autofilter using Maros

bmanicse

New Member
Joined
Apr 16, 2010
Messages
27
I want to identify the text of the selected text from the dropdown menu of an autofilter to utilise it in macros for calculation. How can I identify the text in macros.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
If you have thing it is not a good question pardon my ignorance. I would be happy if somebody has some answer.<o:p></o:p>
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi,

It's doable but not easy.

You'll have to loop through the Autofilter's Filter collection and use some carefully built logic to examine the Filter.Criteria1 and Filter.Criteria2 arguments. It has to be done carefully to avoid raising errors - for example, you'll need to check the Filter.On and Filter.Operator properties to know what can be accessed. In Excel 2007+ it's even tougher because you have other issues such as sorting and colour criteria to contend with.

If you're struggling I do have an old project where I wrote some classes to store the autofilter settings. If you let me know which version of Excel you're using I could probably trim it down to something digestable and close to what you need.
 
Upvote 0
To Colin:

I'm by no means an expert (though I play one on You Tube), but doesn't Filter.Criteria1 just return the selected item in the list with an equal sign in front of it? Why would you have to loop through the Filter collection?

Please pardon my ignorance.
 
Upvote 0
Hi AlphaFrog,

I'm assuming that multiple filters could be filtering. To get the criteria for each filter you'd loop through the filters collection. That's all I meant - nothing outrageous. :)
 
Upvote 0
Hi Colin,

Thanks for the offer. I am uisng office XP pro. I am looking for a code that fires when ever we choose a text from the dropdown list in the autofilter. I tried the worksheet change event, it doesn´t work.

Thanks
 
Upvote 0
To simulate an OnFilter event one could use the Calculate event. Put =COUNTA(A:A) in a spare cell. Then hiding any row, either manualy or via AutoFilter, will trigger a re-calculation of that formula and the Calculate event will fire.
Oddly enough:
Autofilter on one term
Autofilter on the same term

will trigger it twice, its not an AutoFilter_Change event its an ApplyFilter event. (Or HideRows).
 
Upvote 0

Forum statistics

Threads
1,215,949
Messages
6,127,877
Members
449,410
Latest member
adunn_23

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