PDA

View Full Version : Macro todelete a chart if it has zero values using VBA



shaneaon1984
05-07-2014, 03:36 AM
Hi,

Very new to VBA. I have a number of charts in an excel sheet which some have zero values but still get produced.

I want to create a macro that will delete the chart after checking if the values are = 0.

This is my macro so far


Sub OmitZeroMetricCharts()

Dim cht As Chart
Dim s As Series
Dim p As Point
Dim vals As Integer
Dim x As Integer

Set cht = ActiveSheet.ChartObjects(1).Chart
Set s = cht.SeriesCollection(1)

vals = s.Values


If vals = 0 Then
cht.SeriesCollection
Selection.Delete
Else
End If

End Sub

Any help would be excellent.

Thanks

Bob Phillips
05-07-2014, 04:56 AM
Are you saying that if all values are zero, or if there are no values to chart?