RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 810
- Office Version
- 365
- Platform
- Windows
VBA Code:
Range("A2:X" & LastrowBD).AutoFilter Field:=8, Criteria1:=">=" & PrevMon, Criteria2:="<" & PrevMon + 8
Range("A2:X" & LastrowBD).AutoFilter Field:=6, Criteria1:="Donk"
If Not Range("A2:X" & LastrowBD).SpecialCells(xlCellTypeVisible).Count > 1 Then
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
Else
Range("J3:J" & LastrowBD).SpecialCells(xlCellTypeVisible).Copy temp.Range("G2")
Range("M3:M" & LastrowBD).SpecialCells(xlCellTypeVisible).Copy temp.Range("H2")
Range("N3:N" & LastrowBD).SpecialCells(xlCellTypeVisible).Copy temp.Range("I2")
End If
Hi all,
Have the above code that is working fine when results from the two filters are found, however, if the filter supplies no results, I would want it to go showalldata and then move to the next part of code.
The way my book is structured has the data from A2:X6563 or so.
LastrowBD is properly defined further up the code and correctly counts the rows.
When I apply the PrevMon (03/May/2021) filter it works correctly, and then when I apply the Donk filter, nothing is found as expected because we don't sell products under the made up name "Donk"
So yeah, I'm expecting the code to move to the clear filter part, and not the "else" part.
I've confirmed there's no excess data. When I apply the filter, we have the top row in row 1, the headers in row 2 and blank cells in visible row 3 and beyond.
I've also manually double-deleted the entire row of everything under the dataset and it's still not working.
Any ideas? I get the feeling it's crushingly simple as I have this sort of logic on multiple sheets but this is the only one giving me trouble. Thanks!