Change chart source data to variable value

ankita.sethi

Board Regular
Joined
Apr 27, 2011
Messages
58
Hi,

I am trying to change a chart data source to some values of variable that have been calculated in VBA itself, but I am failing to do so :(

The variable names that I have calculated are a, b, c, and ot

I tried doing this:
'change the chart numbers
Sheets("Sheet1").ChartObjects("Chart 3").Activate
ActiveChart.SeriesCollection(1).Values = (a,b,c)
ActiveChart.SeriesCollection(1).Name = "=""ser1"""

However, there is a syntax error in this macro where the text is red.

Can anyone please help me with this?

Regards,
Ankita
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
The Values property expects a formula as a string. Example:

Code:
Sub Test()
    Const a As Long = 10
    Const b As Long = 20
    Const c As Long = 30
    ActiveChart.SeriesCollection(1).Values = "={" & a & "," & b & "," & c & "}"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,629
Members
452,933
Latest member
patv

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