How to Change Excel Cell Fill Color Without Changing Font Color
Question details
The user wants to change the background fill color of rows or cells using an Excel macro while preserving existing font colors, including text that has been manually formatted.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Running a VBA macro to modify cell background colors without resetting or losing custom text formatting.
- Observed behavior
- The macro or workbook event inadvertently resets the font color to default (black) when applying the background fill or when the user clicks out of the cell.
Before modifying your VBA code, ensure you have saved a backup copy of your workbook. Press ALT + F11 to open the VBA Editor and locate the specific macro responsible for modifying your cell formatting.
Modify VBA Code to Target Only Interior Properties
Adjust your macro script so it exclusively updates the cell's background color property without affecting the font properties.
Macros that apply broad cell styles or reset formatting can unintentionally overwrite text colors. By targeting only the Interior properties, you isolate the background fill from the text.
Press ALT + F11 to open the Visual Basic for Applications (VBA) Editor in Excel.
In the Project Explorer pane on the left, find the module containing your formatting macro and double-click to open it.
Review your macro for any lines modifying 'Font.Color' or applying a full 'Style'. Remove or comment out these lines.
Ensure your code uses specific background properties, such as 'Range("A1").Interior.ColorIndex = 3' or 'Interior.Color', to safely change the fill without affecting text.
Disable Conflicting Worksheet Events
If manually colored text resets to black immediately after leaving the cell, a background worksheet event is likely triggering the reset.
Restart Excel and Clear VBA State
Occasionally, VBA execution states can become stuck or cached, causing unexpected formatting behaviors.
Use WPS Spreadsheet to Safely Run Macros and Format Cells
WPS Spreadsheet fully supports VBA macros, allowing you to seamlessly execute scripts that change cell background colors while maintaining your precise text formatting. It offers a powerful, built-in VBA editor that is highly compatible with Microsoft Excel.
- 1. Open Your Macro Workbook: Launch WPS Spreadsheet and open your .xlsm file containing the formatting macro.
- 2. Access the Developer Tab: Navigate to the 'Developer' tab on the top ribbon and click on 'Visual Basic' to launch the VBA Editor.
- 3. Refine the Code: Adjust your code to use '.Interior.Color' for background changes, avoiding '.Font.Color' modifications.
- 4. Run and Verify: Save your changes and run the macro. Your cell fills will update seamlessly while preserving manually applied text colors.

Frequently Asked Questions
Why does my text color turn black when I click out of a cell?
This usually happens if a VBA background event, such as 'Worksheet_Change' or 'Worksheet_SelectionChange', is programmed to automatically reset the cell's font color or clear formatting upon exiting the cell.
How do I change cell background color without using VBA?
You can manually change the background color using the Fill Color bucket tool in the Home tab, or use Conditional Formatting rules to change cell backgrounds automatically based on cell values without altering the font color.
What is the difference between Interior.Color and Font.Color in VBA?
Interior.Color specifically targets and modifies the background fill of the cell itself. Font.Color changes the color of the text within that cell. Keeping these properties separated in your code ensures background changes do not overwrite text colors.




