Chart & Visualization Issues

Replace Chart Titles Across an Excel Workbook with VBA

Nimra MalikNimra Malik Nov 18, 2026 868 views

Question details

Replace text in embedded chart titles across all worksheets in an Excel workbook.

Replace Chart Titles Across an Excel Workbook with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user wants to update chart titles throughout a workbook using VBA instead of changing each chart individually.
Observed behavior
A workbook-wide loop can update matching text in existing titles of embedded charts on every worksheet.
Before you start

Open the workbook in a desktop version of Excel that supports VBA, and make sure the Developer tab is available. Check whether any chart titles are linked to cells, because replacing their text may break those links.

Solution 1Recommended

Run a VBA macro across all worksheets and embedded charts

Use this macro to replace matching text in existing embedded chart titles throughout the workbook containing the macro.

The macro uses ThisWorkbook, so it processes the workbook where the code is stored, not necessarily the active workbook. It skips charts without titles and does not process separate chart sheets.

1
Open the VBA editor

In Excel, open the target workbook, then select Developer > Visual Basic.

2
Insert the macro

In the VBA editor, select the target workbook's project, choose Insert > Module, and paste this code: Sub ChartLabelReplace() Dim ws As Worksheet Dim cht As ChartObject Dim findText As String Dim replaceText As String findText = InputBox("Find:") If findText = "" Then Exit Sub replaceText = InputBox("Replace:") For Each ws In ThisWorkbook.Worksheets For Each cht In ws.ChartObjects If cht.Chart.HasTitle Then cht.Chart.ChartTitle.Text = Replace(cht.Chart.ChartTitle.Text, findText, replaceText) End If Next cht Next ws End Sub

3
Save and run the macro

Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if you want to retain the macro. Select Developer > Macros, choose ChartLabelReplace, and click Run. Enable macros if prompted and you trust the workbook.

4
Enter the replacement text

In the Find prompt, enter the text to replace. In the Replace prompt, enter the new text; leave it blank to remove the matching text. Check the chart titles on your worksheets after the macro finishes.

Run a VBA macro across all worksheets and embedded charts
Linked chart titles: Writing text directly to a chart title can replace a link to a worksheet cell. Update the source cells instead if you need to preserve those links.
Free Microsoft Office alternative

Edit Spreadsheet Chart Titles in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening Excel files and editing chart titles. It can help you move everyday spreadsheet work to WPS, but it does not fix Excel VBA issues; check macro compatibility before migrating automated workflows.

Edit embedded chart titles in WPS Spreadsheets.Open and edit Microsoft Excel .xlsx files.Use a familiar interface for everyday spreadsheet work.Work with a free, lightweight Office alternative.
microsoft office alternative - wps office

Frequently Asked Questions

Does the macro update charts on every worksheet?

Yes. It loops through ThisWorkbook.Worksheets and each worksheet's ChartObjects, updating embedded charts that already have titles.

Will this also update chart sheets?

No. Separate chart sheets are not included in the worksheet ChartObjects loop and require additional VBA code.

Why didn't a chart title change?

Check that the chart is embedded in a worksheet, has a title, and contains the exact find text. Also make sure the macro is stored in the workbook you want to update.

Can I remove text from chart titles instead of replacing it?

Yes. Run ChartLabelReplace, enter the text to remove in the Find prompt, and leave the Replace prompt blank.

How do I keep the macro in the workbook?

Choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). When reopening the file, enable macros only if you trust it.