Chart & Visualization Issues

Change Excel Sunburst Chart Data Label Font Size with VBA

Nimra MalikNimra Malik Nov 14, 2026 868 views

Question details

Change the font size of individual Sunburst chart data labels using VBA.

Change Excel Sunburst Chart Data Label Font Size with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants a VBA macro to format specific labels in an Excel Sunburst chart.
Observed behavior
The macro may appear to change a label's font size without applying it, affect the whole label series, or encounter an error when a label is hidden.
Before you start

Check the chart name in Excel and identify the data label indexes you want to format. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros only if you trust the file.

Solution 1Recommended

Set individual data label font sizes with VBA

Use FullSeriesCollection and TextFrame2 to format specific labels in the Sunburst chart.

1
Open the VBA editor

In Excel, open the worksheet containing the chart and press Alt+F11. In the VBA editor, choose Insert > Module.

2
Add the macro

Paste the following code into the module: Sub SetSunburstLabelSize() Dim chartObject As ChartObject Set chartObject = ActiveSheet.ChartObjects("Chart 1") chartObject.Chart.FullSeriesCollection(1).DataLabels(1).Format.TextFrame2.TextRange.Font.Size = 20 chartObject.Chart.FullSeriesCollection(1).DataLabels(6).Format.TextFrame2.TextRange.Font.Size = 20 chartObject.Chart.FullSeriesCollection(1).DataLabels(7).Format.TextFrame2.TextRange.Font.Size = 20 End Sub

3
Adjust and run the macro

Replace "Chart 1" with your chart's name, change the label indexes and font size as needed, and press F5 while the cursor is inside the macro. Return to the worksheet to check the labels.

Set individual data label font sizes with VBA
Hidden labels and version differences: Excel may automatically hide some labels, and accessing a hidden label can cause an error. In some Excel 64-bit versions, formatting an individual label may affect the entire data-label series.
Free Microsoft Office alternative

Work with spreadsheet charts in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility, making it easy to move everyday spreadsheet work to WPS. It does not fix Excel's VBA or Sunburst label-formatting behavior.

Create and edit spreadsheet charts in WPS SpreadsheetsOpen and save Microsoft Excel formats such as XLSXUse a familiar interface for everyday spreadsheet workMove compatible Office documents into a lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

How do I change the font size of a different data label?

In the VBA macro, replace the number in DataLabels(1) with the desired label index and set Font.Size to the size you want. Run the macro again from the VBA editor.

Why does the macro produce an error for a data label?

Excel may automatically hide a Sunburst label, making it inaccessible to the macro. Check the chart for hidden labels and test the indexes of labels that are visible.

Why are all my Sunburst labels changing size?

Some Excel versions can apply an individual label's formatting to the series. Try right-clicking the data labels, choosing Font, and enabling Equalize character height before running the macro again.

Can WPS Office fix this Excel VBA issue?

No. The issue concerns Excel's chart and VBA behavior. WPS Office is an alternative for compatible spreadsheet work, but it does not repair the Excel-specific problem.