Create Chart from Array values
This code creates a chart from Array values only. Explore and modify this code to make more complex charts using array only.
Sub CreateChartFromArray() Dim objCht As ChartObject With Sheet1 Set objCht = .ChartObjects.Add(10, 20, 500, 200) objCht.Chart.ChartWizard .Cells(1) objCht.Chart.SeriesCollection(1).Values = Array(56, 61, 45, 15, 30, 10) objCht.Chart.SeriesCollection(1).XValues = Array("A", "B", "C", "D", "E", "F") End With Set objCht = Nothing End Sub
»
- Vishesh's blog
- Login or register to post comments
- 41685 reads
it does not work
it does not work
Missing line - Code updated
Sub CreateChartFromArray()
Dim objCht As ChartObject
With Sheet1
Set objCht = .ChartObjects.Add(10, 20, 500, 200)
objCht.Chart.ChartWizard .Cells(1)
objCht.Chart.SeriesCollection.NewSeries 'this line is missing in pvs code
objCht.Chart.SeriesCollection(1).Values = Array(56, 61, 45, 15, 30, 10)
objCht.Chart.SeriesCollection(1).XValues = Array("A", "B", "C", "D", "E", "F")
End With
Set objCht = Nothing
End Sub