簡體   English   中英

在Excel中隱藏行組

[英]Hide group of rows in excel

我想隱藏某些行組,其中空白行之后的第一行是“ xyz”,直到出現下一個空白行。 例如

**heloo**
a
b

**xyz**
as
df

**hello**
g
j

**xyz**
ghj
gh
jk
jk

我希望輸出為

**heloo**
a
b

**hello**
g

看來您已經編輯了問題,所以輸入內容略有不同。 但是,這就是您需要的想法。 基本上,定義一個范圍。 遍歷直到找到xyz。 設置一個標志以開始隱藏迭代中的每一行,直到找到空白行。

Sub HideRows()
    Set r = Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    hiderow = False
    For Each c In r.Cells
        If Left(c.Value, 3) = "xyz" Then
            hiderow = True
        ElseIf Len(c.Value) = 0 Then
            hiderow = False
        End If
        If hiderow Then
            c.Select
            Selection.EntireRow.Hidden = True
        End If
    Next c
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM