I was making a code to filter/sort several sheets of data, and then apply formulas (in the H column and I column) to each (filtered) piece of data.
When there is data that exists from the filtered list, the code works fine. However, if NO data makes it through my filter, then I get the error: "Autofill method of RangeClass failed", because from looking at my code, it tries to count the rows in "A" and then copy the formula in "H" all the way down... but if there aren't any rows, I assume it gets confused? It's important because when there's this error it stops the rest of my subsequent codes from working! Please help!
I put two parts of my code below. They're essentially the same, just for two different sheets with data. The first part for "Line2" works fine because there is data, but the one for "Line3" messes up at the bolded section: Range("H2").AutoFill Destination:=Range("H2:H" & Cells(Rows.Count, "A").End(xlUp).Row
How can I apply some kind of "if" statement for if there is no data shown?
Keep in mind that the list still exists on the page, and jumps from "A2" to "A139" for example, because all of the data is still there just hidden because of the filter. Hence I can't really use if A3="" , for example, because there technically is data in A3 still.
Please Login or Register to view this content.
Bookmarks