我想隐藏某行的行,其中第一行是空行后是“xyz”,直到下一空白行发生。例如隐藏excel中的行组
**heloo**
a
b
**xyz**
as
df
**hello**
g
j
**xyz**
ghj
gh
jk
jk
我想输出是作为
**heloo**
a
b
**hello**
g
我想隐藏某行的行,其中第一行是空行后是“xyz”,直到下一空白行发生。例如隐藏excel中的行组
**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
不太明白。你的例子中的空行在哪里? – sam092
您是否尝试过使用宏录像机开始使用? – ARich