craigwg
08-17-2010, 02:51 PM
I have a chart that I am creating using VBA. The problem is the x-axis can be different each time the chart is built. For example, sometimes there are 5 values to chart, sometimes 20 values or more.
Currently I have the chart statically building and using all available columns in the spreadsheet. But I need it to only build the x axis based on how many values there are. I hope that makes sense. Here is the part of my code that is in question. There is more above and below, but you get the idea.
With ActiveChart
.ChartType = xlLine
.PlotVisibleOnly = False
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name = "='Scrabble'!$H$7"
.Values = "='Scrabble'!$B$10:$S$10" 'This line needs to be dynamic
.Format.Line.Visible = msoCTrue
.Format.Line.ForeColor.RGB = RGB(192, 80, 77) 'Red
End With
Currently I have the chart statically building and using all available columns in the spreadsheet. But I need it to only build the x axis based on how many values there are. I hope that makes sense. Here is the part of my code that is in question. There is more above and below, but you get the idea.
With ActiveChart
.ChartType = xlLine
.PlotVisibleOnly = False
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name = "='Scrabble'!$H$7"
.Values = "='Scrabble'!$B$10:$S$10" 'This line needs to be dynamic
.Format.Line.Visible = msoCTrue
.Format.Line.ForeColor.RGB = RGB(192, 80, 77) 'Red
End With