Use the ListRows
method of your table, looping through each row.
In this case you can print all the rows in the table that passes your criteria of Not ...Hidden
.
Sub printUnhiddenRows()
Dim r As ListRow, tbl As ListObject
Set tbl = ThisWorkbook.Worksheets(1).ListObjects("Table1")
For Each r In tbl.ListRows
If Not r.Range.Rows.Hidden Then Debug.Print r.Range.Row
Next r
End Sub
Worksheets(1)
if the sheet is not #1 in the worksheet collection. .ListObjects("Table1")
if the table is named something else. This could be another solution:
Dim rngTable As Range
Dim country As Range
Set rngTable = Range("Table1[Country]")
rngTable.Select
Selection.SpecialCells(xlCellTypeVisible).Select
For Each country In Selection.Cells
MsgBox country.Row
Next
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.