Hello Jeremy,
Copy this code into your macro module. If the chart doesn't exisit, it will create it. If you want to change the Pie Chart format, let me know.
Sub SetupChartSeries()
Dim LastRow As Long
Dim SourceRng As Range
Dim ChartPlotArea As PlotArea
With ActiveSheet
If .ChartObjects.Count = 0 Then
CreatePieChart
End If
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set SourceRng = .Range("A1:B" & LastRow)
With .ChartObjects(1).Chart
.SetSourceData SourceRng
.ApplyDataLabels Type:=xlDataLabelsShowLabelAndPercent
Set ChartPlotArea = .PlotArea
End With
With ChartPlotArea
.Border.ColorIndex = 2
.Interior.ColorIndex = 2
End With
End With
End Sub
Private Sub CreatePieChart()
Dim NewChart As ChartObject
Set NewChart = ActiveSheet.ChartObjects.Add(200, 100, 500, 300)
With NewChart.Chart
.ChartType = xlPie
End With
End Sub
Sincerely,
Leith Ross
Bookmarks