Hi all,
This is a pretty common question but I can't seem to find a solution that works for me. I have the following code that is supposed to apply autofilter but if the criteria does not exist, I want it to turn off the filter and end if. However, the line
seems to run regardless of the criteria existing or not. Any help would be appreciated!
FYI: The above code is part of a larger procedure so I haven't added any of the variables that i have "dim" and no "end sub". All of that is mentioned in the actual procedure.
This is a pretty common question but I can't seem to find a solution that works for me. I have the following code that is supposed to apply autofilter but if the criteria does not exist, I want it to turn off the filter and end if. However, the line
VBA Code:
If currentBoxRange.Offset(-1, 0).CurrentRegion.SpecialCells(xlCellTypeVisible).Rows.count = 1 Then
VBA Code:
Sheets("Missing_Files").Range("A2:E650").ClearContents
currentBoxRange.Offset(-1, 0).AutoFilter Field:=6, Criteria1:="Missing Files Detected"
'the following line is where I am having difficulty
If currentBoxRange.Offset(-1, 0).CurrentRegion.SpecialCells(xlCellTypeVisible).Rows.count = 1 Then
SARK.AutoFilterMode = False
Else
currentBoxRange.Columns(3).Copy
Sheets("Missing_Files").Range("MissingFiles").Offset(1, 0).PasteSpecial xlPasteValues
SARK.AutoFilterMode = False
End If
FYI: The above code is part of a larger procedure so I haven't added any of the variables that i have "dim" and no "end sub". All of that is mentioned in the actual procedure.