How to Add Chart Title using Macros (VBA) in Excel Office 365?
Tags: addcharttitleusingma, vbamacros
Published: 2021-02-10 11:00:28

---
title: How to Add Chart Title using Macros (VBA) in Excel Office 365?
published: true
date: 2021-02-01 10:31:28 UTC
tags: AddChartTitleusingMa,VBAMacros
canonical_url: https://geekexcel.com/how-to-add-chart-title-using-macros-vba-in-excel-office-365/
---

Do you know how to add a chart title using Macros in Excel? If you don’t, then don’t be worried. We are here to help you to achieve this task quickly. In this article, we will learn the steps to **Add Chart Title using Macros ([VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/)) in Excel Office 365**. Let’s get into this article.
## Add Chart Title using Macros:

Follow the below steps to add chart title using Macros in Excel worksheet.

- In the below screenshot, you can see the **example chart** with some data. We are going to add a title to this chart using Macros.

![Example chart](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/01/EXCEL_KTlygA85qI.png)<figcaption id="caption-attachment-21588">Example chart</figcaption>

- On the **Developer Tab, select** the **Visual Basic** option under the **Code** section.

![Select Visual Basic option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Select-Visual-Basic-option-5.png)<figcaption id="caption-attachment-14839">Select the Visual Basic option</figcaption>

- It will open a new window, where you need to paste the below code.

VBA code to add chart title

‘First, you have to select a chart

Sub AddChartTitle()

Dim titleText As Variant

On Error GoTo Last

‘Get the Chart title

titleText = InputBox(“Please enter the chart title”, “Chart Title Input”)

‘Set the title on the selected chart

ActiveChart.SetElement (msoElementChartTitleAboveChart)

ActiveChart.ChartTitle.Text = titleText

Last: Exit Sub

End Sub

- You need to **save the code** by selecting it. Then **close** the **window.**

![Save the code](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/01/EXCEL_6XTuGZWd7X.png)<figcaption id="caption-attachment-21589">Save the code</figcaption>

- You have to open the sheet containing the data. On the **Developer Tab, choose** the **Macros option** in the **Code** section.

![Choose the Macros option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Choose-the-Macros-option-3.png)<figcaption id="caption-attachment-14841">Choose the Macros option</figcaption>

- Then, you need to make sure that your macro is selected and **click** the **Run** button.

![Click Run button](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/01/EXCEL_XAahM4z2JE.png)<figcaption id="caption-attachment-21590">Click Run button</figcaption>

- After that a new Chart Title Input window will open, you need to **type the title** that you want for your chart.
- Hit the **OK** button.

![Enter chart title](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/01/EXCEL_FoeVRQYuZu.png)<figcaption id="caption-attachment-21591">Enter chart title</figcaption>

- Finally, you will see the added chart title on your chart in the worksheet as shown in the below image.

![Output](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/01/EXCEL_sPBFisxOWr.png)<figcaption id="caption-attachment-21592">Output</figcaption>

## Wind-Up:

In the above article, you can easily understand the steps to **Add Chart Title using Macros (VBA)** in Excel Office 365. Feel free to share your **queries/suggestions** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!