Reputation: 21
I am trying to set SeriesCollection.Values property however, I get the error "Unable to set the Values property of the Series class". I have tried Google for possible solutions, but none have worked yet.
I have used xlNewApp.Sheets("Synchronized Data").Range("H2:H117") in place of "'Synchronized Data'!$H$2:$H$117" and this has not worked either.
I have had some success with typing an array in (e.g. "={58, 77, 65,106}") of the actual data I want to graph, however I would like to avoid looping through all my data to create the necessary array.
Any help on this issue would be appreciated.
The code looks like this:
xlSheetCount = xlNewWorkbook.Worksheets.Count
Dim chart As Excel.Chart = xlNewApp.ActiveWorkbook.Charts.Add(After:=xlNewWorkbook.Worksheets(xlSheetCount))
xlNewWorkbook.ActiveChart.Name = "Chart_Efficiencies"
xlNewWorkbook.Sheets(xlSheetCount).name = "Chart_Efficiencies"
xlNewApp.Charts("Chart_Efficiencies").Select()
xlNewApp.ActiveChart.ChartType = Excel.XlChartType.xlXYScatter
xlNewWorkbook.ActiveChart.SeriesCollection.NewSeries()
With xlNewWorkbook.ActiveChart.SeriesCollection(1)
.ChartType = Excel.XlChartType.xlXYScatter
.Name = "HgT Removal Efficiency"
.XValues = "'Synchronized Data'!$A$2:$A$117"
.Values = "'Synchronized Data'!$H$2:$H$117" <----------- Problem Here
End With
UPDATE: The Code does not error if that line is:
xlNewApp.Sheets("Synchronized Data").Range("H2:H15").Value
When H15 becomes H16, I get the error again
Upvotes: 2
Views: 2326
Reputation: 11
i know this is old and not the subject but i've been looking for that a very long time... and google gives this link, so i'll just put that there in the hope it will help someone..
.(X)Values = New Object() {value1, value2, etc..}
Upvotes: 1
Reputation: 5439
Does it work if you replace these lines:
.XValues = "'Synchronized Data'!$A$2:$A$117"
.Values = "'Synchronized Data'!$H$2:$H$117" <----------- Problem Here
With this:
.XValues = Sheets('Synchronized Data').Range("$A$2:$A$117")
.Values = Sheets('Synchronized Data').Range("$H$2:$H$117")
?
Upvotes: 0