Reputation: 1513
Just starting out with this VBA stuff....
From all the examples I see, the data for charts is based on a range of Cells as seen here :
Sub UpdateChartSourceData()
With ActiveSheet
.ChartObjects(1).Chart.SetSourceData _
Source:=.Range("ChtSourceData"), _
PlotBy:=xlColumns
End With
End Sub
My routine is calculating a few values internally via subroutines and storing the values in variables and not cells on the sheet.
It is these variables that I would like to use as the data for a chart, but have been unable to figure out how to set the Source to be variables from my Subroutine instead of a range of cells.
Do you have a link to any examples?
Upvotes: 0
Views: 249
Reputation: 133
Well this is not an answer to your question but you can take it as an example and try to work it out.
Dim array_value(1 To 10) As Integer
Dim excel_Chart As ChartObject
'Inserting test data - but in your case it has to be done differently
For i = 1 To 10
array_value(i) = i
Next i
Set excel_Chart = Sheets("Sheet1").ChartObjects.Add(50, 40, 200, 100)
With excel_Chart.Chart
.ChartType = xl3DColumn
.SeriesCollection.NewSeries
.SeriesCollection(1).Values = array_value
End With
Hope it helps :)
Upvotes: 1