Hi
I have created a dynamic named range for the criteria of an advanced filter. The dynamic range is needed because I want to allow for entry of between 1 and 6 rows of criteria.
The criteria will be entered in row 7 to row 12, with the headings in row 6.
Beside the filter criteria in O7 to O12 is a formula which calculates if the row is empty (returns 0) or has entries in one or more cells (returns 1). The sum of these is stored in cell P4 (ie. count of rows with entries in them)
The formula for the named range is: =OFFSET('Custom Search & Filter'!$C$6,0,0,1+'Custom Search & Filter'!$P$4,11)
For the advanced filter to function correctly, users must enter criteria from the top row down. If a row is skipped, but more criteria entered in a row further down (ie. criteria in rows 7 and 9, but nothing in row 8), my dynamic criteria range will include rows 7 and 8, and because 8 is blank, the filter will return all results from the list range of the filter. I don't think people would generally skip rows initially, but might not realise that they can't delete out the criteria from a whole row (unless it is the bottom row).
To solve this problem, I want to dynamically clear and hide the criteria rows until the visible row as some data in it. Only then will the next row become visible, and be able to be populated with more criteria.
Hope that makes sense.
I'm very new to VBA, but here is what I've tried so far. I can't make this run without crashing Excel.
![]()
Please Login or Register to view this content.
Can anyone recommend how I can achieve what I'm trying to do?
Thanks!
Bookmarks