代码之家  ›  专栏  ›  技术社区  ›  Sijith

如何隐藏值不等于1、31、61、91等的行序列

  •  -1
  • Sijith  · 技术社区  · 7 年前

    我想隐藏除1,31,61,91121等值以外的所有行

    我的行值被排序并从1递增到29160

    1 回复  |  直到 6 年前
        1
  •  0
  •   Wizhi    7 年前

    更新代码,因为我错过了你的问题(你想要除外)。对于非常大的数据集,由于重新计算工作表,工作簿应用筛选的速度可能很慢。这个VBA代码隐藏所有列,然后显示每30行,希望很容易修改您的目的。

    Sub Hide_Every_nth_Row()
    Dim n As Integer
    
    Range("1:29160").EntireRow.Hidden = True 'Hide all rows from row 1 to 29160
    
    For n = 1 To 29160 Step 30 'start from row 1 and loop to row 29160. After every loop it jump 30 rows.
    Range(Cells(n, 1), Cells(n, 1)).EntireRow.Hidden = False 'Show the nth Row set as "Step". It check the nth row and Column A (A = 1), but since you show the whole row, the column doesn't matter :)
    Next n
    End Sub
    

    n = 1 :从哪一行开始。

    To 29160 :您的最后一行是。

    Step 30 :每次循环要跳多少步,从 n “th值。

    EntireRow.Hidden = False :显示行。将此设置为 True 隐藏每一行。

    推荐文章