Removing a series in a chart

I have a table and want to create a chart. the problem is that I would only like to have the Values ​​A, F, G and H column.

I tried the seriescollection (1) .deletion method. but i still get columns B and C in my chart.

Can anyone tell me how I can do this. Any guidance would be helpful

Sub chartstatus()
Dim Rng As Range
Dim cht As Object

Set Rng = ActiveSheet.Range("A2:H53")
ThisWorkbook.Sheets("Status").ChartObjects.delete
Set Sh = ActiveSheet.ChartObjects.Add(Left:=650, _
    Width:=600, _
    Top:=80, _
    Height:=250)

Sh.Select

Set cht = ActiveChart
With cht
.SetSourceData Source:=Rng
.ChartType = xlColumnClustered
cht.Axes(xlSecondary).TickLabels.NumberFormat = "0.%"

End With


cht.SeriesCollection(6).Name = " % Missing "
cht.SeriesCollection(7).Name = " % OnTime"
cht.SeriesCollection(8).Name = " %  Delayed"


cht.SeriesCollection(6).HasDataLabels = True
cht.SeriesCollection(7).HasDataLabels = True
cht.SeriesCollection(8).HasDataLabels = True
cht.SeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(255, 255, 255) '<~~ Red

cht.HasTitle = True
cht.ChartTitle.Text = "Result "
End Sub

      

+3


source to share


1 answer


You can combine 2 ranges into 1 range



Dim Rng As Range
Dim Rng_A As Range
Dim Rng_FH As Range
Set Rng_A = ActiveSheet.Range("A2:A52")
Set Rng_FH = ActiveSheet.Range("F2:H52")
Set Rng = Union(Rng_A, Rng_FH)

      

+3


source







All Articles