Function Problems

How to Check Cell Fill Color in WPS Excel with a Formula or VBA

Ayan MasoodAyan Masood Nov 13, 2026 869 views

Question details

The user needs to determine whether a cell in column B has the fill color #FFC7CE and, if it does, return the corresponding value from column C to column D.

How to Check Cell Fill Color in WPS Excel with a Formula or VBA
Product
WPS Office Excel
Device & OS
not provided
Scenario
The user is working with a spreadsheet where colored cells indicate a condition and wants to retrieve values from another column based on that formatting.
Observed behavior
Excel and WPS formulas evaluate cell values but cannot directly detect fill color, so a standard formula cannot reliably return the required value.
Before you start

Identify whether the #FFC7CE fill is created by conditional formatting or by manual formatting. If it is conditional formatting, use the underlying value or rule; if it is manual, save the workbook as a macro-enabled file before running VBA.

Solution 1Recommended

Use Conditional Formatting Rules or a Value-Based Formula Instead

Use this method when the fill color is applied by a conditional formatting rule, because Excel can evaluate the underlying condition but not the color itself.

Excel formulas are designed to calculate from cell values and cannot reliably inspect formatting properties such as Interior.Color. When the color represents a condition, checking the condition directly is faster, safer, and works without macros.

1
Open Manage Rules

Select a colored cell in column B, click Home > Conditional Formatting > Manage Rules, and note the formula or condition that applies the #FFC7CE fill.

2
Create a value-based formula

In cell D2, enter a formula that tests the underlying value, for example =IF(B2="TargetValue",C2,""), or use =IFERROR(INDEX(C:C,MATCH($A1,B:B,0)),$C1) if you are matching values from column A.

Use Conditional Formatting Rules or a Value-Based Formula Instead
No paint-format detection: This method only works when the color matches a known value or rule. A standard formula cannot inspect the RGB fill color directly.
WPS Office Excel

Check Cell Fill Color with Conditional Formatting or VBA in WPS Office Excel

Use the underlying conditional formatting condition when possible, or apply a small VBA macro to read the cell’s Interior.Color and return the correct value from another column.

  1. 1. Inspect the fill: Open your workbook in WPS Office Excel, then select a colored cell and click Home > Conditional Formatting > Manage Rules to see if a rule creates the #FFC7CE fill.
  2. 2. Test the underlying rule: If a rule exists, write a formula in D2 that tests the same condition, such as =IF(B2="TargetValue",C2,""), and fill it down.
  3. 3. Add a VBA macro: If the color is manual, press Alt+F11, click Insert > Module, and paste the VBA function that checks rng.Interior.Color = RGB(255,199,206).
  4. 4. Apply the function: Enter the function in D2, for example =GetColorValue(B2,C2), and fill down to return matching values from column C.
  5. 5. Save as macro-enabled: Save the file as .xlsm or enable macros so the workbook retains and runs the VBA macro.
Read fill color conditions without changing your existing Excel workbookUse conditional formatting or VBA directly in a familiar spreadsheet interfaceFull compatibility with .xlsx and .xlsm files from Microsoft OfficeLightweight and free alternative for viewing, editing, and automating Excel workbooks
microsoft office alternative - wps office

Frequently Asked Questions

Can an Excel formula directly read a cell’s fill color?

No. Standard Excel and WPS formulas cannot evaluate fill color; they can evaluate values. Use VBA or conditional formatting instead.

How do I match the exact color #FFC7CE in VBA?

Use the VBA condition cell.Interior.Color = RGB(255,199,206) or check Interior.ColorIndex, then return another cell value.

What formula can return a value from column C if column B has a specific fill color?

There is no pure formula for fill color, but you can create a VBA function and use =GetColorValue(B2,C2) in column D.

Does WPS Office support Excel VBA macros that check cell colors?

Yes. Open the VBA editor with Alt+F11, paste the macro, and save as a macro-enabled workbook (.xlsm); enable macros when prompted.

How can I avoid VBA when colored cells come from conditional formatting?

Click Home > Conditional Formatting > Manage Rules, copy the rule’s condition into a formula, and write that formula in column D.