×

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.

Related Topics

Introduction to Visual Basic Editor Window

How to enable the Developer Ribbon Tab? In order to work with VBA, users need to make a small change in Excel to display a new tab (Developer) at the top of the...

5 minutes read.

Excel VBA MessageBox

Message Box The MsgBox in Excel VBA is a dialog box used to inform the users of your program by showing a custom message or get some necessary inputs such as Yes/No or...

4 minutes read.

Excel VBA Day Function

The function Day in VBA returns the day number (from 1 to 31) for the given date value. Syntax Day (Date) Parameter Date (required) – This parameter represents the date. Return This function returns the day...

1 minute read.

Scope in Visual Basics

Definition of Scope The scope of any programming language implies the area of code where the variables will be identified, accessed, and used. Every variable has a scope associated with it. The scope of...

4 minutes read.

VBA UBound

VBA UBound  The UBound or Upper Bound function in VBA is used to specify the length of an array and returns the highest subscript for a dimension for the specified array. It is...

3 minutes read.

Excel VBA InStrRev Function

VBA InStrRev Function: The InStrRev function in Excel VBA returns an integer representing the position of a substring within the specified string if the substring is fount else it returns...

2 minutes read.

Excel VBA Sqr Function

VBA Sqr Function: The Sqr function in VBA returns the square root for the specified number. Syntax Sqr (Number) Parameter Number (required) – This parameter represents a positive numeric value that you want to calculate...

1 minute read.

VBA ListBox

What is a ListBox? ListBox refers to a permanently displayed control (usually box-shaped) which contains a list of objects (or attribute, or elements) from which the user can select single or multiple attributes....

8 minutes read.

Excel VBA Oct Function

VBA Oct Function: The Oct function in VBA converts the given number into octal notation and returns the result as a string. Syntax Oct (Number) Parameter Number (required) – This parameter represents the numeric value...

1 minute read.

Excel VBA Exp Function

VBA Exp Function: The Exp function in VBA returns the value of the exponential function ex (mathematical constant ‘e’ raised to specified power) for the given value of x. Syntax Exp (Number) Parameter Number (required) –This parameter represents...

1 minute read.

Excel VBA Log Function

VBA Log Function: The Log function in VBA returns the natural logarithm for the specified number. Syntax Log (Number) Parameter Number (required) –This parameter represents a positive numeric value that you want to find the...

1 minute read.

How to save Macro Workbook?

Saving Macro Workbook Default Excel File Extension The default excel file extension is “.xlsx”. But the standard file extension “.xlsx” cannot contains macros. So, the workbook contains macro when save din.xlsx file, all VBA...

1 minute read.

Debugging in Excel VBA

Debugging in VBA: Debugging is a technique used to fix errors in programming languages. In Excel VBA, we have different ways by which you can identify the error in the...

2 minutes read.

Excel VBA Hour Function

The hour function in VBA returns the hour element for the specified time. Syntax Hour (Time) Parameter Time (required) – This parameter represents the time. Return This function returns the hour element for the specified time. Example 1 Sub HourFunction_Example1() ...

1 minute read.

Excel VBA Now Function

Excel VBA Now Function: The Now function in VBA returns the current date and time.  Syntax Now () Parameter NA Return This function returns the current date and time.  Example 1 Sub NowFunction_Example1() 'It will return...

1 minute read.

Excel VBA FormatCurrency Function

VBA FormatCurrency Function: The FormatCurrency function in VBA is used to apply a currency format to a numeric expression and returns the result as a string. Syntax FormatCurrency (Expression, [NumDigitsAfterDecimal], [IncludeLeadingDigit], [UseParensForNegativeNumbers], [GroupDigits]) Parameter Expression (required)...

2 minutes read.

Excel VBA- Pivot Table Fields

VBA- Pivot Table Fields: The Pivot Fields collection contains all the fields from the data source, including any calculated fields. The main aspect of adding a field is its Position...

4 minutes read.

Excel VBA MonthName Function

Excel VBA MonthName Function: The MonthName function in VBA returns a string with the month name for the specified month number. Syntax MonthName (Month, [Abbreviate]) Parameter Month (required) – This parameter represents an integer between...

1 minute read.

Excel VBA Cos Function

VBA Cos Function: The Cos function in VBA returns the cosine value for a supplied angle. Syntax Cos (Number) Parameter Number (required) –This parameter represents the number that you want the absolute value of. Return This function...

1 minute read.

Excel VBA CVar Function

VBA CVar Function: The CVar function in VBA converts an expression into a Variant data type. Syntax CVar (Expression) Parameter Expression (required) – This parameter represents the expression that that you want to convert...

1 minute read.