Using VBA to change the graph series values...Need help

DavidRoger

Board Regular
Joined
Oct 2, 2011
Messages
135
Hi,
I get macro A to work but with same concept the macro B doesn't seem to work. What ever values added after = will be show in the graph series values. I have try function text and value but only show same result. Series value shows ='Sheet1'!$AD$22 instead of ='Sheet1'!$AQ$30:$AQ$90.

Macro A:
ActiveSheet.ChartObjects("Chart 1").Chart.Axes(xlValue).MaximumScale = [R20]

Macro B:
ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(3).Values = [AD20]

Below is the macro I get from recording:
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(3).Name = "=""Line 1"""
ActiveChart.SeriesCollection(3).Values = "='Sheet1'!$AQ$30:$AQ$90"
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
try to use RC formulas r= row and C = column

Code:
"='Sheet1'!$AQ$30:$AQ$90"

it might be like this

Code:
"'Sheet1'!R30C43:R90C43"
 
Upvote 0
Hi,

This is a renew question.

I am working on graph auto update for X-axis. Macro A is for graph format and Macro B is for X-axis.

Macro A:
ActiveSheet.ChartObjects("Chart 1").Chart.Axes(xlValue).MaximumScale = [R2]

Macro B:
ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(3).Values = [AD2]

AD2 = 'Sheet1'!$AQ$3:$AQ$9

Macro A is working but cant get the macro B to work. What ever values added after macro B's = will be show in the graph series values. So there are no link to the spreadsheet. Series value shows ='Sheet1'!$AD$2 instead of ='Sheet1'!$AQ$3:$AQ$9

Below is the macro I get from recording:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(3).Name = "=""Line 1"""
ActiveChart.SeriesCollection(3).Values = "='Sheet1'!$AQ$3:$AQ$9"

May I know what syntax should be replacing [AD2] since it refer to a formula instead of a value? I get this from other forum.

I need [AD2] to be link to the excel spreadsheet because any changes can be directly change in the spreadsheet.

Thank you.
 
Upvote 0
Hi,

This is a renew question.

I am working on graph auto update for X-axis. Macro A is for graph format and Macro B is for X-axis.

Macro A:
ActiveSheet.ChartObjects("Chart 1").Chart.Axes(xlValue).MaximumScale = [R2]

Macro B:
ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(3).Values = [AD2]

AD2 = 'Sheet1'!$AQ$3:$AQ$9

Macro A is working but cant get the macro B to work. What ever values added after macro B's = will be show in the graph series values. So there are no link to the spreadsheet. Series value shows ='Sheet1'!$AD$2 instead of ='Sheet1'!$AQ$3:$AQ$9

Below is the macro I get from recording:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(3).Name = "=""Line 1"""
ActiveChart.SeriesCollection(3).Values = "='Sheet1'!$AQ$3:$AQ$9"

May I know what syntax should be replacing [AD2] since it refer to a formula instead of a value? I get this from other forum.

I need [AD2] to be link to the excel spreadsheet because any changes can be directly change in the spreadsheet.

Thank you.

try to replace
Code:
ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(3).Values = [AD2]

with

Code:
ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(3).Values = "=Sheet1!R3C43:R9C43"
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

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