The starting point for the vast majority of charting code is to create an empty
Chart. Note that this
Chart is subject to the default chart template that is active and may not actually be empty (if the template has been modified).
The key to the
ChartObject is determining its location. The syntax for the call is
ChartObjects.Add(Left, Top, Width, Height). Once the
ChartObject is created, you can use its
Chart object to actually modify the chart. The
ChartObject behaves more like a
Shape to position the chart on the sheet.
Code to create an empty chart
Sub CreateEmptyChart() 'get reference to ActiveSheet Dim sht As Worksheet Set sht = ActiveSheet 'create a new ChartObject at position (0, 0) with width 400 and height 300 Dim chtObj As ChartObject Set chtObj = sht.ChartObjects.Add(0, 0, 400, 300) 'get refernce to chart object Dim cht As Chart Set cht = chtObj.Chart 'additional code to modify the empty chart '... End Sub
if you want to reproduce, please indicate the source:
excel-vba – Charts and Charting – Creating an empty Chart - CodeDay