Yes, your:
Range(("J1"), Range("J1000")).End(xlUp)
will always be just cell J1.
Several things need to be tweaked to make it more robust.
So question 1 is does the data to be filtered (including headers) always start in row 1?
Q 2: Since you're looking to filter the 10th column, the autofilter range needs to be that wide for certain. Is this always goingto be the case?
Q 3: Where is this code (a standard code module, a sheets'code module, perhaps the workbook's code module)? That With statement is going to need its ranges qualified.
Q 4: Using Offset(1) alone to exclude the headers is in danger of including an extra line below the filtered range. This may not matter if you're certain there's never going to be anything at all below that filtered range. It needs to be resized to one fewer rows. Will this matter?
Point 5: Once an autofilter is in place on a sheet, its range can be reliably accessed with its .Range property.
I'll provide specific code on answers to the above 4 questions, with perhaps any additional stuff yopu feel might be important to know.




Reply With Quote

Bookmarks