Criteria in autofilter not met, how can I skip the next script/code?


I have auto filter in macro then copy the filtered file to a different sheet. However, what if there is nothing filtered? He cannot copy anything. How should the script be that it will skip to the copying code and jump to the next filter that has data?




You can do something like this:

row_count = Range("A1:A50").SpecialCells(xlCellTypeVisible).Rows.Count

If row_count > 1 Then

    'copy your data

End If

Range("A1:A50").SpecialCells(xlCellTypeVisible).Rows.Count is the part that returns a row count that is then used to figure out if there is anything to copy. Change th Range in this line to the range that you are filtering.


Answer the Question

You must create an account to use the forum. Create an Account or Login