Using offset in series values of a chart

G

Guest

I have 1 named range created with the offset function on sheet(1):

Month=offset($A$1,0,0,counta($A:$A),1)

Simple to use as the x-as categories in a chart.

For the y-axis I want to use data which can be offset 1, 2, up to 20 columns.
Yes I can create 20 named ranges but to do that for 20 sheets in my workbook
gets cumbersome.
Therefor my question:
Can I use the offset function in the series values, like:
=offset(Month,0,7)

In VBA it it can be done with:
..SeriesCollection(2).Values = Month.Offset(0, 17)
But then I have to create one macro for each graph...again cumbersome.

Please help.

Thx.
Beertje.
 
J

Jon Peltier

You have to create one named range for each set of Y values.

For your charts, if you are making it with VBA, just accept the selected
range from the user, use the first column as the X values, and use each
subsequent column for each series.

' air code
Dim rData As Range
Dim iCol As Long
Dim iChart As Chart
Set rData = Selection
Set oChart = ActiveSheet.ChartObjects.Add(100, 100, 350, 275).Chart
Do While oChart.SeriesCollection.Count > 0
oChart.SeriesCollection(1).Delete
Loop
For iCol = 1 To rData.Columns.Count - 1
With oChart.SeriesCollection.NewSeries
.Values = rData.Columns(iCol + 1)
.XValues = rData.Columns(1)
End With
Next

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top