我想遍历过滤器行,但循环遍历所有列,然后移动到下一行。
Dim wsMain As Worksheet
Dim rngTar As Range
Dim lRow, lCol As Integer
Set wsMain = ThisWorkbook.Sheets("Datewise")
lRow = wsMain.Cells(Rows.Count, 1).End(xlUp).Row
lCol = wsMain.Cells(1, Columns.Count).End(xlToLeft).Column
Set rngTar = wsMain.Range(wsMain.Cells(1, 1), wsMain.Cells(lRow, lCol))
wsMain.AutoFilterMode = False
rngTar.AutoFilter Field:=16, Criteria1:="=KEEP"
For Each rng In rngTar.SpecialCells(xlCellTypeVisible)
MsgBox wsMain.Range("Q" & rng.Row).Value, , wsMain.Range("R" & rng.Row).Value
Next rng
如果我有18列,那么上面的循环将在18次循环后移动下一行