AJS
10-05-2005, 03:29 AM
Hi All,
I'm trying to set up a macro for creating x-y charts based on range selections made by the user. First I use input boxes to ask for the x-values range, as a column, then to ask for the y-values range(s), as one or multiple columns. I'd then like to be able to label the different series based on the value in the cell in the first row of the column containing the y values. Problem is, I'm not sure how to call this. This is the pertinent fragment of the code I'm currently using to add each new series of data:
For i = 1 To YRange.Columns.Count
ActiveChart.SeriesCollection.NewSeries
.SeriesCollection(i).XValues = XRange
.SeriesCollection(i).Values = YRange.Columns(i)
.SeriesCollection(i).Name = ActiveSheet.Cells(1, YRange.Columns(i)).Value
Next i
where XRange and YRange are the users selected ranges. The end result is that no series get named - they all stay as "Series1", "Series2" etc...
Where am I going wrong?
Thanks, Aaron
I'm trying to set up a macro for creating x-y charts based on range selections made by the user. First I use input boxes to ask for the x-values range, as a column, then to ask for the y-values range(s), as one or multiple columns. I'd then like to be able to label the different series based on the value in the cell in the first row of the column containing the y values. Problem is, I'm not sure how to call this. This is the pertinent fragment of the code I'm currently using to add each new series of data:
For i = 1 To YRange.Columns.Count
ActiveChart.SeriesCollection.NewSeries
.SeriesCollection(i).XValues = XRange
.SeriesCollection(i).Values = YRange.Columns(i)
.SeriesCollection(i).Name = ActiveSheet.Cells(1, YRange.Columns(i)).Value
Next i
where XRange and YRange are the users selected ranges. The end result is that no series get named - they all stay as "Series1", "Series2" etc...
Where am I going wrong?
Thanks, Aaron