views:

621

answers:

2

Here is the code that applies an advanced filter to the column A on the Sheet1 worksheet (List range) by using the range of values on the Sheet2 (criteria range)

Range("A1:A100").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        Sheets("Sheet2").Range("A1:A10"), Unique:=False

After running this code, I need to do something with the rows that are currently visible on the screen.

Currently I use a code like this

For i = 1 to maxRow
   If Not ActiveSheet.Row(i).Hidden then
     ...do something that I need to do with that rows
   EndIf
Next

Are there any simple property that can give me a range of rows visible after applying an advanced filter?

+2  A: 

ActiveSheet.Range("A1:A100").Rows.SpecialCells(xlCellTypeVisible)

This yields a Range object.

Lance Roberts
thank you. it works in Excel 2007. Will check in Excel 2003 tommorow
Bogdan_Ch
+1  A: 
Oorang