我试图隐藏错误的行。
目前我有
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Range("B10:B13") = False Then
Target.EntireRow.Hidden = True
End If
End Sub
答案 0 :(得分:2)
尝试迭代范围中的每个单元格并像这样测试其值
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim c As Range
For Each c In Range("B9:B13")
If Not c.Value Then
c.EntireRow.Hidden = True
End If
Next c
End Sub
编辑:我认为您可以实现其他结果的另一种方法是从图表中删除该系列
Dim n As Long
With ChartObjects(1).Chart
For n = .SeriesCollection.Count To 1 Step -1
With .SeriesCollection(n)
If .Name = "" Then
.Delete
End If
End With
Next n
End With
答案 1 :(得分:2)
for i = 9 to 13
if range("B" & i) = "False" then
Rows(i & ":" & i).EntireRow.Hidden = True
end if
next