How to Sum Excel Values Based on Cell Color or Status
Question details
The user wants to calculate the sum of values in Excel based on a specific cell color (like green) or a specific status.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating total values based on the visual status or background color of cells in a worksheet.
- Observed behavior
- The user needs a way to evaluate and sum cells that share a specific background color or status marker, usually bypassing the limitation that standard formulas cannot natively sum by manual cell color without workarounds.
Ensure your data is organized in columns and that you have a clear mapping of what each status or color represents. Using status text (like 'In Stock') instead of manually painting cells makes your formulas much more reliable.
Use SUMIF Based on Status Values (Recommended)
Instead of summing by manual cell color, use a text status column with conditional formatting and the SUMIF function.
Excel's native formulas cannot directly read manually applied cell colors. The most reliable method is to use a status value that drives both the color (via Conditional Formatting) and the calculation (via SUMIF).
Select your status column (e.g., Column L). Go to the 'Data' tab, click 'Data Validation', choose 'List', and enter options like 'In Stock, Ordered, Need to Order'.
Highlight your status column, go to the 'Home' tab, click 'Conditional Formatting', and set a 'Highlight Cells Rule' for 'Text that Contains' to automatically turn cells green when 'In Stock' is selected.
In your designated total cell, enter a SUMIF formula to calculate the corresponding values in your data column (e.g., Column I). Type `=SUMIF(L9:L24, "In Stock", I9:I24)`.
Press Enter to execute the formula. Excel will now sum all the values in Column I where the corresponding status in Column L is marked as 'In Stock'.

Sum Cells by Background Color Using VBA
If you must sum cells based on manually applied background colors, you can create a custom VBA function.
Easily Sum Data by Conditions with WPS Spreadsheet
WPS Spreadsheet provides powerful functions like SUMIF, data validation, and conditional formatting to help you effortlessly track and calculate data statuses. Fully compatible with Microsoft Excel formats, WPS Office allows you to apply status-based calculations efficiently.
- 1. Open your workbook: Launch WPS Spreadsheet and open your data file containing the values and statuses.
- 2. Set up Data Validation: Go to the 'Data' tab on the ribbon, select 'Validation', and create a list of predefined statuses.
- 3. Apply Conditional Formatting: Navigate to the 'Home' tab, click 'Conditional Formatting', and set rules to highlight specific text (like 'In Stock') in green.
- 4. Insert SUMIF Formula: Type `=SUMIF(range, criteria, sum_range)` into your total cell to calculate values dynamically based on the specific text.

Frequently Asked Questions
Does Excel have a built-in function to sum by cell color?
No, Excel does not have a native formula (like SUMIF) that can directly read manually applied cell background colors. You must use a workaround like VBA, or preferably, base your formulas on the cell's underlying value or status text.
Why is my SUMIF formula returning zero?
This usually happens if the criteria in your formula doesn't exactly match the text in the cells, or if there are invisible leading or trailing spaces in your data. Check for typos and ensure the text in your formula matches the status column exactly.
Can I filter by color and then sum the visible cells?
Yes! You can use the Filter tool to filter a column by cell color. After filtering, use the SUBTOTAL function (e.g., `=SUBTOTAL(109, I9:I24)`) to sum only the visible cells that remain on the screen.
Will Conditional Formatting update the sum automatically?
Conditional formatting itself doesn't perform mathematical calculations, but if your SUMIF formula and conditional formatting are based on the same status text (like 'In Stock'), changing a cell's text will simultaneously update both the cell color and the sum total.




