If I have an auto filter set up in Excel and I want to loop through all the visible data in one column with VBA code, what’s the easiest way to do this?
All the hidden rows that have been filtered away should not be included, so a plain Range from top to bottom doesn’t help.
Any good ideas?
Suppose I have numbers 1 to 10 in cells
A2:A11with my autofilter inA1. I now filter to only show numbers greater than 5 (i.e. 6, 7, 8, 9, 10).This code will only print visible cells:
Perhaps there is a better way with
SpecialCellsbut the above worked for me in Excel 2003.EDIT
Just found a better way with
SpecialCells: