Forum Discussion
jukhamil
Sep 22, 2021Brass Contributor
Write a custom filter
Is it possible to write a custom filter, either in VBA or just normal Excel filtering functions, rather than using the pre-existing ones in Excel? For example, in Excel you can hide / filter out dupl...
jukhamil
Sep 23, 2021Brass Contributor
Thanks very much.
What about passing any VBA function as the criteria - a named function I have written in my VBA editor - instead of this sort of Excel-style function? Is that possible with the VBA AdvancedFilter function or should I just write my own filter manually by using the Row.Hidden = True property?
What about passing any VBA function as the criteria - a named function I have written in my VBA editor - instead of this sort of Excel-style function? Is that possible with the VBA AdvancedFilter function or should I just write my own filter manually by using the Row.Hidden = True property?
HansVogelaar
Sep 23, 2021MVP
You can use a VBA function in the formula in cell E2 in my example, as long as it returns TRUE or FALSE for the first cell of the source range. You can use the criteria range in the WorksheetFunction.AdvancedFilter function too.
If that doesn't suit your needs, you can create your own filter code of course, but it will probably be slower.