Filter Question VBA

MattH1

Board Regular
Joined
Jul 15, 2016
Messages
174
I am running a code that filters a large set of data and puts that data into a new file and manipulates it.
I would like to add a few lines to this code that store the filters that do NOT give any data.

For example:

Code:
'Filters column V to only one criteria
        ActiveSheet.Range("$A1:$Y" & RowCount).AutoFilter Field:=22, Criteria1:= _
        "A"
'If filter yields no results, go to next filter
If Range("$A1:A" & RowCount).SpecialCells(xlCellTypeVisible).Count = 1 Then
    GoTo Filter2
End If

In this case, Filter2 is the next filter (Which would filter for the Criteria B in the same column).
How do I institute a line of code that would, at the end of the entire process, tell me which items yielded no filtered results? It would me a MsgBox saying
"The following items returned no filter results: A, C, G"
OR
"The following items returned no filter results:
A
C
G"

I would much prefer the second one since the filters aren't A,B,C, etc. but rather large strings of text.

Thanks!
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Can we see the rest of the code?
 
Upvote 0
Can we see the rest of the code?

It's nearly a thousand lines of code, it is just putting it into a new document and delimiting and then removing/adding columns and rows and such. And then it goes back to the original worksheet and unfilters the data and then refilters the data (aka starts over).
It's a repetition of this 15 times. I know the code I need has to be within that If statement to move to the next filter is no results show, I just don't know how to make that code.
 
Upvote 0
Tried a few different things to no avail. Can't figure out how to store the ones unfiltered but not store the filtered ones (in terms of putting it out in a message box without all the spacing).
 
Upvote 0
Is the code basically doing the same thing over and over again but with different parameters/criteria?

Are you repeating a lot of code?
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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