Reputation: 13
I want hide the chart on the some specific condition like if corresponding cell is blank the chart should be invisible. but once that cell value is not blank then again chart should be visible. I have the below program, but it doesnt work for me. please help.
Sub chart_visibility()
ActiveWorkbook.Sheets("RP0004").Activate
If Range("H32").Value = "" Then
ActiveSheet.Charts("Chart 5").Visible = False
Else
ActiveSheet.Charts("Chart 5").Visible = True
End If
End Sub
Upvotes: 1
Views: 455
Reputation: 166316
E.g:
Sub chart_visibility()
With ActiveWorkbook.Sheets("RP0004")
.ChartObjects("Chart 5").Visible = (Len(.Range("H32").Value)>0)
End With
End Sub
You want the ChartObjects
collection and not the Charts
collection
Upvotes: 1