Excel Sum If Cell Is Yellow: Practical Ways to Do It

Formulas & functions · Updated November 2, 2026

Excel Sum If Cell Is Yellow: Practical Ways to Do It

Excel cannot directly sum cells by fill color with SUMIF or another built-in worksheet formula. To total yellow cells, use a helper column with a label, filter the colored rows and calculate a subtotal, or use a VBA function if the color itself must drive the result.

Why SUMIF Cannot Check a Cell’s Fill Color

SUMIF adds values that meet a condition in the cell contents, such as a name, number, or date. A fill color is formatting, not a value stored in the cell for ordinary worksheet formulas to test. That distinction matters: a formula can evaluate the text “Yellow” in a cell, but it cannot use “the cell looks yellow” as its criteria in the same way.

For example, yellow might mean an item is approved, overdue, or selected for review. If that meaning is important to the calculation, it is usually more reliable to store the status explicitly in a column and use the color only as a visual cue. This keeps the calculation understandable and avoids relying on formatting that someone may change accidentally.

There are workarounds, but they suit different situations. A helper column is usually the most robust choice for a maintained workbook. Filtering is useful for a quick total or occasional review. A VBA function can inspect direct fill colors, but it has macro and recalculation limitations that should be understood before relying on it.

Choose a Method That Matches the Workbook

Before changing the sheet, consider why the cells are yellow and how often the total needs to update. These questions help identify the method that will be least fragile:

  • Does yellow represent a business status? Add a status field such as Approved or Review, then base the sum on that field.
  • Is this a one-time total? Filter the relevant rows by color and use a subtotal.
  • Must the actual fill color determine membership? A VBA user-defined function can compare direct fill colors, provided macros are allowed.
  • Is yellow applied by conditional formatting? Use the rule’s underlying condition instead of trying to read the displayed color.

Color totals can be useful for auditing or legacy workbooks, but color is a weak data category. It can be hard to interpret for people using screen readers, may be changed without updating a formula, and can be applied inconsistently. Where possible, keep the meaning in text or another field, then use conditional formatting to display it in yellow.

Most Reliable Option: Add a Helper Column

Suppose amounts are in B2:B10 and a status column in C2:C10 contains the word Yellow for rows that should be included. With that layout, the following formula sums the amounts whose status is Yellow:

=SUMIF(C2:C10,"Yellow",B2:B10)

If the matching amounts are 12, 7, and 23, the result is 42. The arithmetic is 12 + 7 + 23 = 42. The text in the helper column is the criterion; the cell color is no longer being used as hidden data.

You can also make the helper field clearer by using meaningful labels such as Approved, Hold, or Include. If the yellow fill marks records for review, for instance, store Review in the status field and color that status with conditional formatting. Then the formula can refer to the label that communicates the actual business meaning.

For an existing sheet, add a status column and label each row based on the intended rule. Avoid assuming that every yellow cell means the same thing until you have checked the workbook: users may have applied yellow for different reasons. Once the labels are consistent, the total will update when a status or amount changes, without requiring macros or a manual refresh after formatting.

Quick Total: Filter by Color and Use SUBTOTAL

For a one-off total, filter the table so that only the yellow rows remain visible, then calculate a subtotal over the amount column. If amounts are in B2:B10, this formula adds visible values and excludes rows hidden by the filter:

=SUBTOTAL(109,B2:B10)

For example, if filtering leaves amounts of 12, 7, and 23 visible, the result is 42. The function number 109 means SUM while excluding manually hidden rows as well as rows hidden by a filter. If you do not need to exclude manually hidden rows, function number 9 is another SUM option, but 109 is often convenient for a filtered list.

In Excel for Microsoft 365 on Windows, select the data and choose Data > Filter. Open the dropdown on the column containing the colored cells, then choose Filter by Color > Cell Color and select yellow. Excel displays the matching rows; enter the subtotal formula in a cell outside the filtered list. Clear the filter when you want to see all rows again.

This is not a persistent “sum yellow” formula in the same sense as a normal criteria formula: the result follows which rows are visible. It is useful for checking a total, but a reader may not realize that the figure depends on an active filter. Add a note or keep the filter state visible if others will use the workbook. Also check that the formula cell is outside the filtered range so it is not hidden with the records.

Using VBA to Sum Direct Fill Colors

If the direct fill color must determine which numbers are added, a small VBA user-defined function can compare each cell’s fill with a sample cell. The following function checks the cell’s direct fill, not a color that is only displayed because of conditional formatting. In Excel for Microsoft 365 on Windows, press Alt+F11, choose Insert > Module, and paste the code into the standard module.

Function SumByColor(ByVal dataRange As Range, ByVal colorCell As Range) As Double
    Dim cell As Range
    Dim total As Double

    ' Add numeric cells whose direct fill matches the sample cell.
    For Each cell In dataRange.Cells
        If cell.Interior.Color = colorCell.Interior.Color Then
            If Not IsError(cell.Value2) Then
                If IsNumeric(cell.Value2) Then
                    total = total + CDbl(cell.Value2)
                End If
            End If
        End If
    Next cell

    SumByColor = total
End Function

Assume the amounts are in B2:B5, B2, B4, and B5 have direct yellow fills, B3 is not yellow, and D1 is a yellow sample cell. Enter this formula in a worksheet cell:

=SumByColor(B2:B5,D1)

If B2, B3, B4, and B5 contain 12, 18, 7, and 23 respectively, the function returns 42: it includes 12 + 7 + 23 and leaves out 18. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm), and enable macros only for files you trust. On a Mac, VBA is available in desktop Excel, but the keyboard shortcut to open its editor can depend on the keyboard; use Excel’s Developer tab or the Visual Basic Editor command if the Windows shortcut does not apply.

Important limitations apply. Formatting a cell does not normally trigger worksheet recalculation, so changing a fill may leave the displayed result unchanged until you force a recalculation, for example with F9, or otherwise cause the formula to calculate again. The function also depends on macros being enabled. Save a copy of the workbook before running or adding VBA; macro actions cannot be undone with Ctrl+Z. The code is best reserved for controlled workbooks where these trade-offs are acceptable.

Conditional Formatting Needs a Different Approach

A yellow appearance does not always mean the cell has a direct yellow fill. A conditional formatting rule can display yellow when a value meets a condition, even though the underlying cell formatting is different. The VBA function above checks Interior.Color, which reads direct formatting; it does not reliably identify the color shown by a conditional formatting rule.

When the fill comes from a rule, use the rule’s logic as the sum condition. For example, if yellow means that a status is Review, sum rows where the status says Review. If it means a value is below a threshold, use that numeric condition in the formula. This approach calculates the reason a cell is yellow rather than trying to infer the reason from its appearance.

In Excel, inspect the rules through Home > Conditional Formatting > Manage Rules. Check which range the rule applies to and what condition it evaluates. If several rules can color a cell, determine which rule takes precedence and what the desired total should include. A cell may look yellow because of one rule while another rule also applies, so the visual result alone may not reveal the intended logic.

Common Problems and Checks

  • Different shades of yellow: A color-comparison method may treat different shades as different fills. Choose a consistent fill or use a status field.
  • Conditional formatting: A direct-fill VBA function may not match the displayed yellow. Sum using the condition that triggers the rule.
  • Stale VBA result: A fill change alone may not recalculate the function. Force a recalculation or prefer a helper column.
  • Hidden or filtered rows: A SUBTOTAL result changes with the visible rows. Check the filter before interpreting the number.
  • Text values in the amount range: A sum adds numeric values, not number-like text in every circumstance. Convert intended amounts to numbers and check for errors.
  • Macro restrictions: If macros are disabled or the file is saved as a macro-free format, the custom function may not be available.

For a dependable result, test the method with a small set of rows whose expected total is known. Change one status, fill, or filter at a time and check whether the result changes as intended. This catches a particularly common mistake: summing cells that look yellow now, when the real requirement is to sum cells that met a rule at a particular point in time.

Which Method Should You Use?

For shared reports, recurring calculations, and workbooks that need to remain easy to audit, use a helper column or the underlying business condition. That makes the criteria visible to other people and works without macros. Use a color filter with SUBTOTAL for a quick inspection when a manual step is acceptable.

Choose VBA only when the fill itself is genuinely the data to inspect, the workbook can use macros, and users understand that formatting changes may require recalculation. A color-driven function can be convenient, but it is less transparent than a normal formula and can behave unexpectedly when colors are conditional or inconsistent. Excel for the web does not run VBA macros, so a workbook relying on this function needs desktop Excel with macros enabled.

Frequently Asked Questions

Can SUMIF sum cells based on fill color? No. SUMIF checks cell values against a criterion; it does not test a cell’s fill color. Use a helper column, a filtered subtotal, or VBA for direct fill colors.

How do I sum yellow cells without VBA? Put a clear label such as Yellow or Review in a helper column and use SUMIF on that label. For a temporary total, filter by cell color and use SUBTOTAL on the amount range.

Will the VBA function work with conditional formatting? The example compares direct cell fills using Interior.Color. It does not reliably read the displayed color produced by conditional formatting. Use the rule’s underlying condition instead.

Why did my color-based total not change after I changed a fill? A formatting change does not usually trigger worksheet formula recalculation. Force a recalculation, or switch to a helper column that changes as part of the data.

Does a color-filtered SUBTOTAL include hidden rows? SUBTOTAL with function number 109 excludes rows hidden by filters and rows hidden manually. Its result reflects the currently visible records, so clearing or changing the filter can change the total.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.