How to Fix Missing Category Names in Excel Doughnut Chart VBA Labels
Question details
The user needs to resolve an issue where Excel VBA fails to correctly populate category names in doughnut chart data labels, leaving only a separator like a colon and a space.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Generating or updating a doughnut chart's data labels using a VBA macro.
- Observed behavior
- The VBA script adds only a colon and space to the data labels instead of the actual category names, because the chart's CategoryNames collection does not return the expected text values.
Verify that your chart is pointing to the correct data range in your worksheet and ensure your workbook is saved in a macro-enabled format (.xlsm) before editing the VBA code.
Read Category Names Directly from the Worksheet Range
Bypass the unreliable CategoryNames collection by fetching the text directly from the source cells in your worksheet.
When the chart's CategoryNames collection fails to return the expected values in VBA, the most reliable workaround is to extract the category name directly from the worksheet cells containing your data.
This method ensures accuracy regardless of how the chart interprets the data range, allowing you to manually construct the perfect data label string.
Press ALT + F11 to open the Visual Basic for Applications (VBA) editor and locate the module containing your chart macro.
Determine the exact worksheet range, including the row numbers and column index, where your chart's category names are stored (e.g., column A).
Update your VBA code to iterate through the data points of the doughnut chart series using a For loop.
Use the code `categoryName = ws.Cells(rowNumber, categoryColumn).Value` to read the specific category name. Then, set the label text: `point.DataLabel.Text = categoryName & ": " & pointValue`.

Reassign the Chart Category Range Using VBA
Ensure the chart series is explicitly pointing to the correct X-values (category labels) range in your macro.
Use WPS Office for Reliable Spreadsheet Management and Macros
If you frequently encounter VBA charting limitations in Microsoft Excel, consider switching to WPS Office. It offers a lightweight, highly compatible alternative with excellent support for VBA macros and complex spreadsheet charting, without the hefty subscription fees.
- 1. Download and Install: Visit the official WPS Office website to download and install the free suite on your device.
- 2. Open Your Workbook: Launch WPS Spreadsheets and open your .xlsm file containing the doughnut chart and VBA code.
- 3. Run Your Macros: Enable macros when prompted and execute your VBA scripts to generate charts smoothly.

Frequently Asked Questions
Why does my Excel VBA chart label only show a colon?
This typically occurs when your macro concatenates the category name and the value (e.g., separating them with a colon), but the chart's CategoryNames collection fails to recognize the labels, returning an empty string or null for the category name portion.
Can I format individual data labels in a VBA doughnut chart?
Yes. You can iterate through the Points collection of a Series in VBA and access the DataLabel object for each specific point. This allows you to customize its font, color, formatting, and custom text.
How do I reference a specific cell value for a chart label in VBA?
You can use the Cells property in conjunction with the worksheet object, such as `Worksheets("Sheet1").Cells(row, column).Value`, to retrieve the exact text from a cell and assign it directly to the DataLabel.Text property.




