VBA Charts

What is a Chart?

A chart is used to visually show numbers or data in a spreadsheet (or spread over multiple spreadsheets) so that the end-user can look at the chart and interpret the results or observe the trends easily.

Excel gives an advantage to the user to create customized charts, instantly displaying the data in a visually attractive manner for users. The user can easily manipulate the charts placed within a worksheet or a chart sheet. There are several types of charts in excel, unlike Column chart, Line chart, Bar chart, Stacked chart (bar, line, column), Pie chart, & Bubble charts with Column Bar being the most commonly used.

Charts are created either by directly working with the chart object that defines the chart data. In order to get to the object without an existing chart, you create a ChartObject on a given Worksheet and then get the Chart object from it.

Parts of a Charts

VBA Charts

A - Horizontal Axis: – It is also known as the X-axis. It consists of different values of the variable for which we are plotting data on the graph.

B - Primary Vertical Axis: – It is also known as Y-axis. It consists of a scale based on different data points we are plotting on the graph.

C - Secondary Vertical Axis:– It is not present in all the graphs and is used when we are plotting two different variables on the graph, and there is a huge value difference between the two variables – for example, we are plotting age and salary – age will be in 10’s multiples whereas Salary in 1,000’s – so if we plot them on the same Y-axis, age graph/line/data-points will not be visible at all.

D - Data-Points: – It represents the values that we are plotting on the graphs like age, salary, units, etc,.

E - Chart Title: – It represents the title of the chart, which you can change, link to a cell, or even can format as per your requirement.

F - Legend: – The legend is a sort of key. It informs the users regarding the values that have been plot on the graphs.

G - Data Label: – When you plot values on a graph, you may also want to see the values of each of these data-points, and these values are called Data Labels.

H - Title Axis: – It denotes the title for the horizontal and vertical axis, unlike in the above example we have used Name and Salary on our Title axis.

Embedded Charts vs Chart sheets

Embedded ChartsChart Sheets
These charts are set within a worksheet & and can be shown along with the data or any other informationChart sheets are represented as a separate sheet in the workbook. It contains only a single chart in which the source data or any other information is not displayed.
It can be seen together with other facts in a worksheet.It cannot be a part of the worksheet.
It is saved as part of the worksheet on which it is created.It is saved with is its own sheet name.
These charts are to display or print one or more charts within the worksheet.These charts are used to review or amend large or complicated charts individually from the worksheet data. It is also used when the user wants to preserve screen space to work upon the worksheet.