简体   繁体   中英

EXCEL VBA Specialcells read row

I am working with tables in Excel (ListObject). I apply filter via VBA on a table which work fine. I would like to read specific row (or row, col) from filtered table. I tried with SpecialCells which return a range of cells. But I would like to iterate as rows like listobject.listrows(N) where n is number of row. I didn't find any example. Of course I can iterate cell by cell and locate the the row via formula. But I wonder if exist a better way.

For instance: I would like filter a table with several criteria and update certain columns with a particular value.

I hope I am clear with my question. thanks.

You can loop rows like this

Option Explicit
Sub test()
    Dim rng As Range
    With ActiveSheet.ListObjects(1).DataBodyRange
        For Each rng In .SpecialCells(xlCellTypeVisible).Rows
            Debug.Print rng.Address
        Next rng
    End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM