[英]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.