ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. Count and Sum Colored Cells in Excel

Count and Sum Colored Cells in Excel

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

Excel has no built-in function to count colored cells. The quickest way is to filter the column by color, then use =SUBTOTAL(103,range) to count or =SUBTOTAL(109,range) to sum the visible cells. If the color comes from a rule, such as scores under 50, count the rule instead: =COUNTIF(B2:B8,"<50") is more reliable than counting color.

Key takeaways

  • No standard Excel function reads a cell's fill color, so you count colored cells with a filter, Find, VBA or the rule behind the color.
  • Filter by Color, then =SUBTOTAL(103,B2:B8) counts and =SUBTOTAL(109,B2:B8) sums only the visible cells.
  • Find and Replace with a format shows how many cells have a fill color, but not colors from conditional formatting.
  • A VBA function can count by color, but it doesn't update when a color changes and needs a macro-enabled file.
  • The most reliable method is to count the reason for the color with COUNTIF or SUMIF.
On this page+
  1. Why can't COUNTIF count colored cells?
  2. Method 1: Filter by color, then use SUBTOTAL
  3. Method 2: Find all cells with a fill color
  4. Method 3: A short VBA function
  5. Method 4: Count the rule, not the color
  6. Which method should you use?
  7. Practise it

To count colored cells in Excel, you need a workaround, because no built-in function reads a cell's color. COUNTIF, SUM and the rest look at values, not formatting. The best method depends on where the color came from: filter by color and use SUBTOTAL for colors you painted by hand, or count the rule itself when conditional formatting did the coloring. This guide shows four methods on one small table, from the quickest to the most reliable.

All the examples use this score list in A1:B8. Scores under 50 are filled red.

AB
1StudentScore
2Amara72
3Ben45 (red)
4Chloe88
5Diego39 (red)
6Esi64
7Farid51
8Grace47 (red)

The right answer is 3 red cells, with a total of 131 (45 + 39 + 47).

Why can't COUNTIF count colored cells?#

COUNTIF checks what is in a cell, such as a number or text, not how the cell looks. A fill color is formatting, and Excel's worksheet functions ignore formatting. So =COUNTIF(B2:B8,"red") counts cells that contain the word red, and returns 0 here. The COUNTIF function guide lists what the criteria can match.

Method 1: Filter by color, then use SUBTOTAL#

This is the fastest no-code way to count and sum colored cells. A filter hides the rows you don't want, and SUBTOTAL ignores hidden rows.

  1. Click any cell in the table and turn on the filter: Data > Filter (Windows: Ctrl+Shift+L; Mac: ⌘⇧F).
  2. Click the arrow on the Score header, point to Filter by Color, and pick the red fill.
  3. Click an empty cell in the header row, such as D1. The filter never hides row 1, so the result stays visible. Type:
Excel formula
=SUBTOTAL(103,B2:B8)

The result is 3. To sum the same cells, use function number 109:

Excel formula
=SUBTOTAL(109,B2:B8)

Put it in E1. The result is 131. Clear the filter and both formulas go back to counting and adding every row: 7 and 406.

Function numberDoesIgnores filtered rowsIgnores rows you hid by hand
3Count non-empty cells (COUNTA)YesNo
103Count non-empty cells (COUNTA)YesYes
9SumYesNo
109SumYesYes

Filter by Color works for colors you applied yourself and for colors from conditional formatting. The guide to the SUBTOTAL function and the SUBTOTAL reference page explain the other function numbers, and summing only visible cells shows the same idea with AGGREGATE. If filters are new to you, read how to filter data in Excel or practise filtering a table.

Method 2: Find all cells with a fill color#

Find and Replace can search by format and tells you how many cells it found. This works in Excel for Windows:

  1. Select B2:B8 and press Ctrl+F.
  2. Click Options, then Format > Choose Format From Cell, and click one red cell.
  3. Click Find All. The bottom of the dialog shows 3 cell(s) found.
  4. To get a sum too, press Ctrl+A while the results list is active. Excel selects those cells, and the status bar at the bottom of the window shows their Count and Sum.

This is a quick one-off check. It doesn't leave a formula behind, so the number won't update when colors change. It also only finds colors you applied directly, not colors from conditional formatting.

Method 3: A short VBA function#

A small VBA function can read the fill color of each cell. VBA is the macro language built into desktop Excel. Use it only if you are comfortable with macros:

  1. Press Alt+F11 (Mac: Tools > Macro > Visual Basic Editor) to open the editor.
  2. Choose Insert > Module and paste this code:
Function CountColor(rng As Range, sample As Range) As Long
    Dim c As Range
    For Each c In rng
        If c.Interior.Color = sample.Interior.Color Then CountColor = CountColor + 1
    Next c
End Function
  1. Close the editor. Fill cell G1 red as a sample, then type =CountColor(B2:B8,G1) in any empty cell. The result is 3.
  2. Save the file as an Excel Macro-Enabled Workbook (.xlsm), or the code is lost.

Know the limits before you rely on it:

  • Changing a color does not trigger a recalculation, so the result can be out of date. In Excel for Windows, press Ctrl+Alt+F9 to recalculate everything. On any version, retyping a value in the range also refreshes it.
  • It reads only colors you applied by hand. Colors from conditional formatting are invisible to it.
  • Macros don't run in Excel for the web, and many companies block them.

Method 4: Count the rule, not the color#

When a color means something, count that meaning instead. In this table, red means "score under 50". So:

Excel formula
=COUNTIF(B2:B8,"<50")

returns 3, and

Excel formula
=SUMIF(B2:B8,"<50")

returns 131. These formulas update instantly, work in every version of Excel and never miss a cell.

If people color cells by hand to mark something, such as "paid" or "urgent", add a Status column and type the word instead. Then COUNTIF does the work, a conditional formatting rule can add the color automatically, and you can still sort the list by color or by status. Color then becomes a display of your data, not the data itself.

Which method should you use?#

Pick the method that matches where the color came from:

Color came fromBest method
A conditional formatting ruleCOUNTIF or SUMIF with the same condition
Manual fills, one-off countFind by format, or Filter by Color
Manual fills, a number that stays on the sheetFilter by Color with SUBTOTAL, or a Status column
Manual fills, many reports, macros allowedThe VBA function

Practise it#

Counting with a condition is the skill behind the most reliable method, and it is a common job-test task. Try the exercise on this page, then practise COUNTIF in a live spreadsheet, where each formula is checked instantly. To get fast with filters and SUBTOTAL too, practise filtering a table.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Scores under 50 are colored red by a conditional formatting rule. Count the red cells by counting the rule: in E2, type =COUNTIF(B2:B8,"<50") and press Enter.

fx
ABCDEF
1
Student
Score
2
Amara
72
Red cells
3
Ben
45
4
Chloe
88
5
Diego
39
6
Esi
64
7
Farid
51
8
Grace
47
9
10
11

Tip: The range is the Score column. The criteria is the rule behind the red color, in quotes: "<50".

Practise this in a lesson

LessonFilter a tableTurn on filter buttons with Ctrl+Shift+L, filter by one or several values and by a number condition, total and count only the visible rows with SUBTOTAL, then clear the filters.LessonCOUNTIFCount the cells that match a condition, from exact words to number checks like ">=8".Function guideSUBTOTALTotal filtered lists and grouped data without double counting using SUBTOTAL. Function codes 9, 109 and more, plus a live exercise.Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and a live exercise.

Frequently asked questions

Is there a formula to count colored cells in Excel?

+

Not a built-in one. COUNTIF and the other functions read values, not formatting. You can filter by color and use SUBTOTAL, use Find with a format, or write a small VBA function.

How do I count cells by color without VBA?

+

Turn on a filter, choose Filter by Color on the column, then put =SUBTOTAL(103,B2:B8) above the table. SUBTOTAL counts only the rows the filter shows, so the result is the number of cells with that color.

How do I sum cells by color in Excel?

+

Filter the column by color, then use =SUBTOTAL(109,B2:B8). It adds only the visible cells. If the color comes from conditional formatting, SUMIF with the same condition as the rule gives the same answer without filtering.

Why doesn't my count by color update?

+

Changing a cell's fill color is not a change Excel recalculates for. VBA functions that count colors only update after a recalculation, so press Ctrl+Alt+F9, or count the rule behind the color instead.

Can I count cells colored by conditional formatting?

+

Filter by Color works with conditional formatting colors, so SUBTOTAL after the filter counts them. Find by format and simple VBA functions do not see them. The easiest method is COUNTIF with the same condition as the rule.

Sources

  • SUBTOTAL function - Microsoft Support
  • Filter data in a range or table - Microsoft Support
  • COUNTIF function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Why can't COUNTIF count colored cells?
  2. Method 1: Filter by color, then use SUBTOTAL
  3. Method 2: Find all cells with a fill color
  4. Method 3: A short VBA function
  5. Method 4: Count the rule, not the color
  6. Which method should you use?
  7. Practise it

Keep reading

Math· 5 min read

How to Sum Only Visible (Filtered) Cells in Excel

To sum only visible cells in Excel, use SUBTOTAL instead of SUM. =SUBTOTAL(9,C2:C8) adds only the rows left showing after you filter. =SUBTOTAL(109,C2:C8) also skips rows you hid by hand. SUM always adds every cell, hidden or not. AGGREGATE(9,5,C2:C8) does the same and can skip error values too.

Data tools· 5 min read

SUBTOTAL in Excel: Totals That Ignore Filtered Rows

SUBTOTAL calculates a total that skips rows hidden by a filter: =SUBTOTAL(109,D2:D11) adds only the visible amounts, while SUM adds every row. The first argument picks the calculation: 9 or 109 sums, 1 or 101 averages, 3 or 103 counts non-empty cells. The 100s also skip rows you hid by hand.

Data tools· 5 min read

How to Filter Data in Excel (Ctrl+Shift+L)

To filter data in Excel, click any cell in your table and press Ctrl+Shift+L (Mac: ⌘⇧F), or choose Data > Filter. Arrow buttons appear in the header row. Click an arrow, untick (Select All), tick the values you want and click OK. Hidden rows aren't deleted: clear the filter and they come back.

More on conditional math

  • How to Count Duplicates in Excel
  • How to Count Unique Values in Excel
  • How to Count Yes, No and Ticks in Excel
  • How to Use COUNTIF in Excel (With Criteria Examples)
  • COUNTIF From Another Sheet in Excel
  • COUNTIF Between Two Numbers in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free