vba chart problem.

Lochnagar

New Member
Joined
Jan 28, 2008
Messages
43
hi

I have a vba question/problem regarding inputing the xvalues and yvalues for a data series into a chart using vba.

I used the macro recorder and manually inputed into the 'Source Data' window/menu of the chart the x and y values for the data series, which generated the following...

ActiveChart.SeriesCollection(2).XValues = "='Recycle valves'!R5C3:R32003C3"
ActiveChart.SeriesCollection(2).Values = "='Recycle valves'!R5C10:R32003C10"


As I have a lot of data series that I need to input into the chart I was hoping that I could use the basic outline of the code above in a For Next loop see below...

for i = 1 to 5
ActiveChart.SeriesCollection(i).XValues = "='Recycle valves'!R5Ci:R32003C3"
ActiveChart.SeriesCollection(i).Values = "='Recycle valves'!R5Ci:R32003C10"

Next

...such that for each new series that is added to the chart the column that is referenced in the worksheet is offset for each data series e.g. if i = 1 that I'd get R5C1:R320... or if i = 4 I'd get R5C4:R320... etc.

I have tried the above, but to no avail and I was hoping that someone might be able to point me in the right direction in terms of achieving the above...assuming it is possible.

Any suggestions/advice etc will be greatly appreciated.

Thanks,

Lochnagar
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try:

Code:
For i = 1 to 5
    ActiveChart.SeriesCollection(i).XValues = "='Recycle valves'!R5C" & i & ":R32003C3"
    ActiveChart.SeriesCollection(i).Values = "='Recycle valves'!R5C" & i & ":R32003C10"
Next
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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