Currently I have a number of checkboxes, which the user clicks to graph certain data. Obviously in some instances, more than one checkbox is checked, so I would like to graph more than one graph, however with the following code I have, every graph after the first one (which works fine) fails with run-time error 1004 "Application - defined or Object- defined error". The line .setSourceData is highlighted with that error. Any help? Do I need to make a chartObjects?
Thanks much.
Code:Sub AddChartSheet(chartName As String, setRange As String, yTitle As String, graphStyle As Integer) Dim chtChart as Chart Set chtChart = Charts.Add With chtChart .Name = chartName If graphStyle = 2 Then .ChartType = xlColumnClustered ElseIf graphStyle = 1 Then .ChartType = xlLine End If .SetSourceData Source:=Sheets("SOILSYM_MONTH").Range(setRange), _ PlotBy:=xlColumns 'Link to the source data range. .HasTitle = True .ChartTitle.Text = chartName .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = yTitle .SeriesCollection(1).Delete End With End Sub




Reply With Quote