Filter Criteria Test

Geoff Taylor

Active Member
Joined
Dec 11, 2006
Messages
257
I have code that passes criteria to a column filter.

" ActiveSheet.Range("$A$66:$G$13900").AutoFilter Field:=7, Criteria1:=Range("$B$8").Value"

What I would like to do is test the filter to ensure that there is actually some data that matches the criteria. I know I could loop down the entire range and test each cell but that would take additional time and I wondered if there was some property of the filter I could take advantage of instead.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Perhaps like this

Code:
If IsNumeric(Application.Match(Range("$B$8").Value, Range("G66:G13900"), 0)) Then ActiveSheet.Range("$A$66:$G$13900").AutoFilter Field:=7, Criteria1:=Range("$B$8").Value
 
Upvote 0
Thank you, that's great. A follow-up question...

I now want to do a second test on a second filter in the table.

<Code>If IsNumeric(Application.Match("Y", Range("F66:F13900").SpecialCells(xlCellTypeVisible), 0)) Then</Code>

This code doesn't detect the visible "Y" cells. Testing the line in the "immediate" window gives an "Error 2042"
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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