Creating a graph using variables

Overkill32

New Member
Joined
May 13, 2011
Messages
49
I'm trying to create a scatterplot containing 2 series and using variables that I defined using the same macro. The code i came up with is :

[...]

'Delete the chart's old values
'
Worksheets("GRAPHS").Select
ActiveSheet.ChartObjects("Issuer_Comp").Activate
ActiveChart.ChartArea.ClearContents
'
'Create the new chart using the desired Series'
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.SeriesCollection(1)
.XValues = "=DATA_" & b & "!" & Issuer1M
.SeriesCollection(1).Values = "=DATA_" & b & "!" & Issuer1Y
.SeriesCollection(1).Name = b & " " & i
.SeriesCollection.NewSeries
End With
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.SeriesCollection(2)
.XValues = "=DATA_" & c & "!" & Issuer2M
.SeriesCollection(2).Values = "=DATA_" & c & "!" & Issuer2Y
.SeriesCollection(2).Name = c & " " & j
End With
ActiveChart.ChartTitle.Characters.Text = "Hello World"
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScale = MyDate
.MaximumScaleIsAuto = True
End With

Variables b, c and all the Issuers are strings. Variable i and j are also strings but consisting of numbers.

Each time i get to the bold and underlined line, i get an 1004 application defined or object defined error.

Can anyone help me to fix this little problem plz?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I am now getting a error 1004 " Unable to set the Xvalues property of the Series class" when i run the code.

Are both problem related? The same?
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,901
Members
452,948
Latest member
Dupuhini

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