ValuationMan
New Member
- Joined
- Jun 30, 2017
- Messages
- 49
- Office Version
- 365
- Platform
- Windows
- MacOS
I want to create a pie chart and set the source data. I've spent a long time searching, with this being the most helpful. I keep getting this error, "run time error 2147221080 (800401a8): automation error" for the following code.
Code:
Sub createchart()
Charts.Add
With ActiveChart
.ChartType = xlPie
.Location where:=xlLocationAsObject, Name:="Sheet1"
.SetSourceData Source:=Range("Sheet1!A2:A7,Sheet1!B2:B7"), PlotBy:=xlColumns
End With
End Sub