Excel guide · 6 min read
How to count colored cells in Excel
=SUBTOTAL(103,A2:A11), which counts only the visible rows. For a count that stays right, count whatever the color stands for instead, for example =COUNTIFS(E2:E11,"",D2:D11,"<"&H2) for unpaid invoices past their due date.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Invoice | Client | Amount | Due | Paid on | Status | As of | |
| 2 | INV-1041 | Harbor Dental | 1850 | Sep 30, 2026 | Sep 28, 2026 | Paid | Nov 3, 2026 | |
| 3 | INV-1042 | Kestrel Media | 4200 | Oct 10, 2026 | Overdue | |||
| 4 | INV-1043 | Ridgeway Farms | 760 | Oct 15, 2026 | Oct 20, 2026 | Paid | ||
| 5 | INV-1044 | Bluefin Studio | 2375 | Oct 20, 2026 | Overdue | |||
| 6 | INV-1045 | Juniper Books | 1120 | Oct 31, 2026 | Overdue | |||
| 7 | INV-1046 | Northgate Gym | 980 | Nov 10, 2026 | Open | |||
| 8 | INV-1047 | Cobalt Print | 3050 | Oct 5, 2026 | Oct 4, 2026 | Paid | ||
| 9 | INV-1048 | Maple & Co | 615 | Oct 25, 2026 | Overdue | |||
| 10 | INV-1049 | Orchid Florals | 1490 | Nov 15, 2026 | Open | |||
| 11 | INV-1050 | Summit Tutoring | 2200 | Sep 20, 2026 | Overdue |
Download this sheet as an Excel practice file (.xlsx)
Why COUNTIF can't count colors
Fill color is formatting, not part of the cell's value. COUNTIF, SUMIF and every other worksheet function look only at values, and changing a color does not even make Excel recalculate. There is no hidden criterion like "red" that works.
A few things look as if they should work and don't. CELL("color", A2) only reports whether the cell's number format shows negative numbers in color; it says nothing about the fill. The old GET.CELL macro function can return a fill color number, but only through a defined name in Name Manager, only in desktop Excel, only in a workbook saved as .xlsm, and it does not update when you recolor a cell until something forces a recalculation. A VBA function has its own catch, covered in the FAQ.
So the honest options are: count the colored cells by hand with a filter or Find, or count the condition the color was showing in the first place. The invoice list here has the overdue invoices filled red: Kestrel Media, Bluefin Studio, Juniper Books, Maple & Co and Summit Tutoring.
Method 1: Filter by Color, then SUBTOTAL
This is the fastest one-off answer and it works on any fill, including colors added by conditional formatting. Once the list is filtered, the status bar at the bottom left shows something like "5 of 10 records found". For a number you can use in the sheet, SUBTOTAL ignores the rows the filter hides.
Use 103 to count non-empty cells and 109 to sum. Put the formula above the header or in a cell beside the data, never inside the rows being filtered, or it disappears with them. With no filter on, the count below returns every invoice; filtered to red it returns only the red ones.
The catch: the result is only right while the filter is on, and only for colors that are exactly the same. A slightly different red, picked from More Colors, is a separate entry in the Filter by Color menu.
- Click any cell in the list and choose Data > Filter (Ctrl+Shift+L).
- Click the filter arrow on the Invoice column, then Filter by Color, and pick the red fill.
- In H4, type
=SUBTOTAL(103,A2:A11)to count the visible invoices, and in H5=SUBTOTAL(109,C2:C11)to total their amounts. - Clear the filter with Data > Clear when you're done. The SUBTOTAL formulas go back to counting every row.
Result: 10
10 with no filter on: every invoice is visible. Filtered to the red fill, the same formula returns 5.
Method 2: Find All by format
Find can search by fill color and tells you how many cells it found, with no filter and no formula. It is handy when the colored cells are scattered across columns, which a filter cannot handle.
Two gotchas. Choose Format From Cell copies the whole format, so a cell with the same red but a different font or number format will not match; picking just the fill on the Fill tab avoids that. And Find only sees colors you applied directly. Cells colored by conditional formatting are not found, so use Method 1 or Method 3 for those.
- Select the range to search, then press Ctrl+F (Home > Find & Select > Find).
- Click Options, then the Format button next to Find what.
- On the Fill tab, pick the red, or click Choose Format From Cell and click a red cell. Leave Find what empty and click OK.
- Click Find All. The bottom of the dialog shows the count, such as "5 cell(s) found".
- To add them up, press Ctrl+A while the results list is active to select every found cell, close the dialog and read Sum and Count in the status bar.
Method 3 (best): count the rule behind the color
Colors almost always mean something: overdue, over budget, missing, failed. Whatever made a cell red, by hand or with a conditional formatting rule, can be written as a condition. Count that condition and the number is always right, needs no filter, and updates the moment the data changes.
Here an invoice is red when it has no paid date and its due date is before the as-of date in H2. COUNTIFS takes those two tests directly. A blank criterion ("") matches empty cells, and "<"&H2 compares each due date with the as-of date. In a live sheet, use "<"&TODAY() instead of H2.
If the red came from a conditional formatting rule, open Home > Conditional Formatting > Manage Rules to read its formula, then copy its logic into COUNTIFS. The color and the count can then never disagree.
Result: 5
5 overdue invoices: Kestrel Media, Bluefin Studio, Juniper Books, Maple & Co and Summit Tutoring.
Sum by color with a helper column
When the rule has several parts, or you want to count and sum several colors, give it its own column. Column F labels each invoice Paid, Overdue or Open with one IF formula, and SUMIF or COUNTIF can then use the label like any other value. The same column can drive the conditional formatting (a rule such as =$F2="Overdue"), so the color follows the data.
For cells someone colored by hand with no rule at all, the fix is to stop using color as data. Add a Status column with a drop-down (Data > Data Validation > List, with Paid,Overdue,Open as the source), have people pick a status instead of a color, and let conditional formatting color the rows from it. You get the same red rows and a count that works with COUNTIF, PivotTables and filters.
Result: 10510
$10,510 is overdue: 4,200 + 2,375 + 1,120 + 615 + 2,200.
Which method to pick
One quick count on a sheet you received: filter by color and read the status bar, or use SUBTOTAL if you need the number in a cell. Colored cells spread over many columns: Find All. Anything you will count again next week, or a report other people read: count the condition with COUNTIFS, or a helper status column, and let the color come from the same rule.
Avoid building reports on hand-applied color. It is invisible to formulas, lost when data is pasted as values or exported to CSV, and easy to get slightly wrong, since two reds that look identical can be different colors.
Common mistakes
Trying COUNTIF(A2:A11,"red")
That counts cells containing the word red. No COUNTIF criterion refers to fill color. Count the condition behind the color instead.
Putting SUBTOTAL inside the filtered rows
The formula's own row can be hidden by the filter. Put it above the header or in a column outside the list.
Using Find on conditional formatting colors
Find matches formats applied directly to cells, so it finds nothing. Filter by Color does see conditional formatting, and the rule itself can be counted with COUNTIFS.
Trusting a count after someone recolors a cell
Color changes do not trigger recalculation, so GET.CELL and VBA color counts can go stale. A count built on values updates every time.
FAQ
Is there a formula to count cells by color in Excel?
Not a built-in one. Worksheet functions read values, not formatting. Filter by color and use SUBTOTAL(103,range), or count the condition the color represents with COUNTIF or COUNTIFS.
How do I sum cells by color in Excel?
Filter the column by color and use =SUBTOTAL(109,C2:C11), which adds only the visible rows. For a lasting total, add a status column and use SUMIF on it, as in =SUMIF(F2:F11,"Overdue",C2:C11).
Can I count cells colored by conditional formatting?
Filter by Color sees them, so filtering plus SUBTOTAL works. Find, GET.CELL and a VBA function using Interior.Color do not. The best answer is to count with the rule's own logic in COUNTIFS.
Why doesn't my VBA count-by-color function update?
Changing a fill color is not a recalculation event, so the function keeps its old answer until you press F9 or edit a cell. It also reads only directly applied fills: DisplayFormat, which sees conditional formatting colors, does not work inside a function called from a cell.
How do I sort or filter by cell color?
Turn on Data > Filter, click a column's arrow and choose Filter by Color or Sort by Color. Data > Sort also has Sort On: Cell Color, which lets you put several colors in a chosen order.
Functions used
SUBTOTALTotal that skips other subtotalsCOUNTIFSCounts with several conditionsCOUNTIFCounts cells that matchSUMIFAdds cells that matchIFPicks a result from a testTODAYToday’s date
Related guides
- Highlight overdue and upcoming dates in Excel
- Highlight an entire row based on one cell's value
- How to sum only visible cells in Excel
- COUNTIFS with multiple criteria in Excel
- How to count cells that are not blank in Excel
- How to count blank cells in Excel
Updated