Hey everyone,
I'm attempting to apply many different filters to a set of data and at the end have a message box of what filters yielded no results. Here is a sample of what the code looks like:
This code continues for nearly 20 different filters. I was looking to create lines of code that would, at the END of this process, create a message box the states:
"The following filters yielded no results:
A
C
X"
How could I go about creating something like this? Any and all help is appreciated, I'm stumped because I can't figure out how to store all of them and output them in the message box (since I don't know how many results it will yield each time).
I'm attempting to apply many different filters to a set of data and at the end have a message box of what filters yielded no results. Here is a sample of what the code looks like:
Code:
'Filters column V to only one criteria
ActiveSheet.Range("$A1:$AZ" & 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
'Code that copies visible cells over to a new sheet based on other constraints.
Filter2:
'Filters column V to only one criteria
ActiveSheet.Range("$A1:$AZ" & RowCount).AutoFilter Field:=22, Criteria1:= _
"B"
'If filter yields no results, go to next filter
If Range("$A1:A" & RowCount).SpecialCells(xlCellTypeVisible).Count = 1 Then
GoTo Filter3
End If
'Code that copies visible cells over to a new sheet based on other constraints.
Filter3:
This code continues for nearly 20 different filters. I was looking to create lines of code that would, at the END of this process, create a message box the states:
"The following filters yielded no results:
A
C
X"
How could I go about creating something like this? Any and all help is appreciated, I'm stumped because I can't figure out how to store all of them and output them in the message box (since I don't know how many results it will yield each time).