Sub CreateExampleChartVersionII()
Dim ws As Worksheet
Dim rgChartData As Range
Dim myChart As Chart
Set ws = ThisWorkbook.Worksheets("Basic Chart")
Set rgChartData = ws.Range("B1").CurrentRegion
Set myChart = Charts.Add
Set myChart = myChart.Location(xlLocationAsObject, ws.Name)
With myChart
.SetSourceData rgChartData, xlColumns
.HasTitle = True
.ChartTitle.Caption = "Version II"
.ChartType = xlColumnClustered
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = "Year"
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Caption = "GDP in billions of $"
End With
End With
Set myChart = Nothing
Set rgChartData = Nothing
Set ws = Nothing
End Sub
|