我有一个包含大约 13k 行的 Excel 文件。
我隐藏了一些列,然后根据其他一些列进行过滤。在此之后我还剩下 100-150 行。到目前为止我的宏有效。
下一步是过滤掉具有值的行< 10 in column AH.
我可以以此作为第一步,但当循环 100-150 行就足够时,循环 13k 行似乎很乏味。
我尝试了两个版本。
Dim LR As Long
Dim iCell As Range
LR = Range("A" & Rows.Count).End(xlUp).Row
Set iCell = Range("A2:BS" & LR).Cells.SpecialCells(xlCellTypeVisible)
For Each iCell In Range("AH:AH").Cells
If iCell.Value < 10 Then Rows(iCell.Row).EntireRow.Hidden = True
Next iCell
Dim cl As Range, rng As Range, LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Set rng = Range("A2:BS" & LR)
For Each cl In rng.SpecialCells(xlCellTypeVisible)
If cl.Value < 10 Then Rows(cl.Row).EntireRow.Hidden = True
Next cl
如何仅循环已过滤的剩余 100-150 行范围?
也许试试这个:
Dim cl As Range, LR As Long, ws As Worksheet
Set ws = ActiveSheet ' or whatever
LR = ws.Range("A" & Rows.Count).End(xlUp).Row
For Each cl In ws.Range("AH2:AH" & LR).SpecialCells(xlCellTypeVisible)
If cl.Value < 10 Then cl.EntireRow.Hidden = True
Next cl