You have a column shaded green for “done” and red for
“blocked”, and you want a live count of each. Unlike
SUMIF or COUNTIF, there is no worksheet
function that looks at a cell’s fill colour or
font colour — colour isn’t a value the
formula engine can see. You have three options.
Method 1 — Filter by color and read the status bar
Good for a one-off check. Nothing to install.
- Select your range and choose Data → Create a filter.
- Click the filter icon in the column header, then Filter by color → Fill Color (or Text Color) and pick the colour.
- Select the now-visible cells. The count appears bottom-right in the status bar; click it to switch between Count, Sum, Average and so on.
Method 2 — A custom function you paste yourself
Free and it stays in the sheet — but you also own the upkeep, and this snippet only counts. Open Extensions → Apps Script, paste this, and save:
Back in the sheet: =COUNTBGCOLOR("B2:B100", "D1").
- The range must be passed as a string (
"B2:B100"), because a normal range argument gives Apps Script only the values, never the colours. - Changing only a colour does not recalculate the sheet, so the number goes stale until you edit a value, reopen the file, or add an
onEdittrigger that forces a refresh. - It reads exact hex colours, so a “green” applied by conditional formatting (which isn’t a real fill) won’t be matched — only manual fills count.
- It only counts. A sum, average or min/max by colour is a separate near-identical function each — and font colour instead of fill is another one again.
- The script lives in this spreadsheet only. Every other file you want it in, you paste it again and re-authorise; every collaborator does the same in their copy.
Method 3 — The Custom Count & Sum add-on
Install once and the functions are in every spreadsheet on your account — the ones you have now, the ones you make later, and the ones people share with you — with no code to paste or keep working. You get 38 formatting-aware functions covering every aggregation, plus a refresh so colour changes actually register. After installing Custom Count & Sum:
Beyond the basic count, the add-on version adds:
- a plain hex string instead of a reference cell —
=COUNTBACKGROUNDCOLOR("A2:A100", "#46bdc6"); - several ranges at once —
=COUNTBACKGROUNDCOLOR({"A2:A100","D2:D100"}, "C1"); - colour and font style in one test with
COUNTCOLORANDSTYLE; MIN,MAXandMEDIANby colour, plus cross-sheet variants.
The full list is on the function reference.
=COUNTIF(A2:A100, ">100")).
Which method should you use?
| Filter by color | Own script | Add-on | |
|---|---|---|---|
| Setup | None | Paste & maintain code | One-click install |
| Lives in the sheet as a number | No | Yes | Yes |
| Updates after a colour change | Manual re-filter | Only with a custom trigger | Yes, via built-in refresh |
| Multiple colours / ranges, sum & average | One at a time | More code | Built in |
| Available in your other spreadsheets | — | No — paste per file | Yes — every sheet on your account |
| Upkeep | Re-filter each time | You own every fix & addition | Updates itself |
| Cost | Free | Free | Free up to 30 cells per formula, then a plan |
Use Filter by color for a one-off look, a custom function if you need one colour counted in one sheet and don’t mind the recalc caveat and maintaining the code, and the add-on when colour is part of how you track work, you want sums and averages too, or you need the same functions across more than one spreadsheet.
Count by colour without writing a script
Custom Count & Sum adds 38 formatting-aware functions to Google Sheets. Free for formulas up to 30 cells.
Install free from Google Workspace Marketplace