logo
search
VBA & Macro Problems

How to Change Excel Cell Fill Color Without Changing Font Color

Maira MehtabMaira Mehtab Sep 20, 2026 868 views

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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press ALT + F11 to open the Visual Basic for Applications (VBA) Editor in Excel.

2
Locate Your Formatting Macro

In the Project Explorer pane on the left, find the module containing your formatting macro and double-click to open it.

3
Edit the Code

Review your macro for any lines modifying 'Font.Color' or applying a full 'Style'. Remove or comment out these lines.

4
Apply Interior Color

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.

Safe Formatting: Using Interior.ColorIndex, Pattern, TintAndShade, and PatternTintAndShade guarantees the font color remains intact.
Advanced Macro Formatting

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. 1. Open Your Macro Workbook: Launch WPS Spreadsheet and open your .xlsm file containing the formatting macro.
  2. 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. 3. Refine the Code: Adjust your code to use '.Interior.Color' for background changes, avoiding '.Font.Color' modifications.
  4. 4. Run and Verify: Save your changes and run the macro. Your cell fills will update seamlessly while preserving manually applied text colors.
Highly compatible with Microsoft Excel (.xlsx and .xlsm formats)Built-in VBA editor for running and debugging macrosPrecise control over cell styling and text formattingFree and lightweight office suite
microsoft office alternative - wps office

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.