Adding a Chart Sheet Using VBA Code

Vertex42 The Excel Nexus

Professional Excel Templates

Get Instant Access

The recorded code is a bit odd. There is no need to create an embedded chart. You can simply add a chart sheet and set its properties directly. You can also create an object variable, so that you have a simple and efficient way of referring to the chart in subsequent code. Rather than limit yourself to the preset layouts, you can select the chart features you want, such as a title. There is no need to plot by columns and then plot by rows. The following code incorporates these changes:

Sub AddChartSheet() Dim cht As Chart

'Create new chart sheet Set cht = Charts.Add

With cht

'Specify source data and orientation .SetSourceData Source:=Sheets("Sales")

PlotBy:=xlRows .ChartType = xlColumnClustered


, _

'Add a title and assign it a value

.HasTitle = True

.ChartTitle.Text =




End Sub

Was this article helpful?

0 0
The Accidental Blogging Millionaires

The Accidental Blogging Millionaires

Get Inspired By The Most Popular Bloggers Online! If You Want To Skyrocket Your Success With Business And Improve Your Overall Life You Need To Have A Look At The Accidental Blogging Millionaires! Business can be a fight, particularly when you’re trying to establish one online and like all fights, to succeed you must find the winning techniques and apply them.

Get My Free Ebook

Post a comment