How to Keep Custom Colors in Excel Dynamic Charts Using VBA
Question details
The user needs to prevent custom chart colors from reverting to default settings when reopening an Excel dashboard or changing dynamically selected data.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Updating or filtering data in a dynamic chart dashboard, usually controlled by drop-downs or dynamic formulas.
- Observed behavior
- Custom applied chart colors automatically reset to the default theme colors upon reopening the file or when the dynamic data selection refreshes.
Ensure that your workbook is saved as a Macro-Enabled Workbook (.xlsm), as you will need to use VBA to force the chart to retain your custom color formatting.
Use a VBA Macro to Reapply Chart Colors Dynamically
Since Excel does not natively save custom color mappings for changing dynamic chart data, a VBA script triggered by a drop-down change or recalculation will automatically reapply your chosen colors.
When dealing with dynamic charts linked to formulas or drop-down menus, Excel often overrides custom colors with default theme colors as the underlying series data changes or refreshes. Writing a simple VBA event macro is the most reliable way to enforce your custom color palette.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in your active workbook.
In the Project Explorer pane on the left side, double-click the specific worksheet containing your dynamic chart and drop-down menu.
Select 'Worksheet' from the first drop-down at the top of the code window, and 'Change' from the second. Write a macro that targets your ChartObject (e.g., ActiveSheet.ChartObjects("Chart 1")) and assigns your specific RGB values to the SeriesCollection.Format.Fill.ForeColor.RGB whenever the target cell containing the drop-down is modified.
Close the VBA editor and save your file as an Excel Macro-Enabled Workbook (.xlsm) to ensure the code runs successfully every time the file is opened.
Create and Manage Dynamic Charts Seamlessly with WPS Office
WPS Spreadsheets provides powerful charting tools and full support for VBA macros, allowing you to easily maintain custom chart colors and design interactive dashboards without formatting issues.
- 1. Open Your Workbook in WPS: Launch WPS Spreadsheets and open your existing .xlsx or .xlsm file containing the dynamic chart.
- 2. Enable the Developer Tab: Go to the 'Developer' tab on the top ribbon and click 'Visual Basic' to access the macro editor.
- 3. Apply Chart Formatting Macros: Use the built-in VBA editor to insert your color-preservation code, ensuring your charts look perfect even when data refreshes.

Frequently Asked Questions
Why do my Excel chart colors change when I filter data?
When data series change dynamically or empty series are recreated through formulas or filters, Excel redraws the chart using the active document theme colors, discarding any manual color overrides you previously applied.
Can I save my chart as a template to keep the custom colors?
Saving a chart template (.crtx) helps apply formatting to new charts manually, but it will not automatically enforce custom colors on an existing dynamic chart when its source data selection changes.
How do I find the correct RGB color codes for my VBA macro?
Select a shape or cell with your desired color, click the 'Fill Color' drop-down on the Home tab, select 'More Colors', and check the Custom tab to see the Red, Green, and Blue (RGB) values required for your code.




