Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

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

0

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?

Answer
Discuss

Answers

0

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.

Discuss


Answer the Question

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