Deleting the first series in a chart

Boogerbut74

New Member
Joined
Oct 17, 2022
Messages
26
Office Version
  1. 365
Platform
  1. Windows
[
VBA Code:
Sub Test_7()
    
    Dim lastrow As Integer
    Dim GraphRange As Range
    
    lastrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 10).End(xlUp).Row
    
    'set chart data range (including series names)
    Set GraphRange = ActiveSheet.Range("D10:T" & lastrow)
    
    'Create a chart
    Set cht = ActiveSheet.ChartObjects.Add( _
    Left:=ActiveCell.Left, _
    Width:=450, _
    Top:=ActiveCell.Top, _
    Height:=250)
    
    'Give chart some data
    cht.Chart.SetSourceData Source:=GraphRange

    
    
    'Determine the chart type
    cht.Chart.ChartType = xlXYScatterSmooth
    'edits chart detailes
    cht.Chart.Axes(xlCategory).MinimumScale = 0
    cht.Chart.Axes(xlCategory).MaximumScale = 100
    
    cht.Chart.Axes(xlValue).MinimumScale = 115
    cht.Chart.Axes(xlValue).MaximumScale = 140
    
    cht.Chart.Legend.Position = xlLegendPositionBottom
 
     
    [B] ActiveChart.FullSeriesCollection(1).Delete
    [/B]
    
End Sub

I am trying to delete my first series in my chart.
With the sheet i am working with I can not move the data around. i have tried using record macro and then trying to rewrite the code to work in my original code but i keep getting Object Variable or With variable not set
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
VBA Code:
cht.select
ActiveChart.FullSeriesCollection(1).Delete

or

VBA Code:
 cht.Chart.FullSeriesCollection(1).Delete
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top