Replace Chart Titles Across an Excel Workbook with VBA
Question details
Replace text in embedded chart titles across all worksheets in an Excel workbook.

- 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.
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.
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.
In Excel, open the target workbook, then select Developer > Visual Basic.
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
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.
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.

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.

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.




