Guides

Count or sum cells by font style in Google Sheets

Bold, italic, underline, strikethrough — Google Sheets can’t filter or count on any of them out of the box. Here are the three ways that work, and where each one falls short.

You strike through the rows you’ve dealt with, or bold the ones that matter, and now you want a running count — or a sum of their values. Google Sheets has no COUNTIF for formatting: whether a cell is bold or struck through isn’t something the formula engine can read. You have three options.

Method 1 — Tag the cells, then filter

Google Sheets can Filter by color, but there is no “filter by bold” or “filter by strikethrough”. The only no-code route is to convert the style into something a filter can see:

  1. Give every styled cell a distinct fill colour (select them — hold Ctrl to pick several — and apply one fill).
  2. Data → Create a filter, then the column’s filter icon → Filter by color → Fill Color.
  3. Select the visible cells and read Count / Sum in the status bar, bottom-right.
Limits: you’re tagging cells by hand, the count doesn’t stay in the sheet, and nothing updates when the styling changes. Fine for a one-off on a short range, unworkable for a list that keeps moving.

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:

/** * Count cells in a range that match a font style. * style: "bold" | "italic" | "underline" | "line-through" * Pass the range as a text string: =COUNTFONTSTYLE("B2:B100", "bold") */ function COUNTFONTSTYLE(rangeA1, style) { var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var range = sheet.getRange(rangeA1); var weights = range.getFontWeights(); // "bold" | "normal" var styles = range.getFontStyles(); // "italic" | "normal" var lines = range.getFontLines(); // "underline" | "line-through" | "none" var n = 0; for (var r = 0; r < weights.length; r++) { for (var c = 0; c < weights[r].length; c++) { var match = (style === "bold" && weights[r][c] === "bold") || (style === "italic" && styles[r][c] === "italic") || (lines[r][c] === style); if (match) n++; } } return n; }

Back in the sheet: =COUNTFONTSTYLE("B2:B100", "line-through").

Watch out for:
  • The range must be passed as a string ("B2:B100") — a normal range argument gives Apps Script only the values, never the formatting.
  • Changing only a cell’s style does not recalculate the sheet, so the number goes stale until you edit a value, reopen the file, or add an onEdit trigger that forces a refresh.
  • Summing instead of counting means a second near-identical function; averaging, min and max mean more still.
  • 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 — now and later — with no code to paste or keep working. You get every aggregation by style, plus a refresh so style changes actually register. After installing Custom Count & Sum:

# count the struck-through cells in B2:B100 =COUNTSTYLE("B2:B100", "line-through") # sum / average the values of the bold cells =SUMSTYLE("B2:B100", "bold") =AVERAGESTYLE("B2:B100", "italic") # style lives in column A, values in column B =SUMPRODUCT(ISFONTSTYLE("A2:A100", "bold") * B2:B100)

Beyond the basic count, the add-on version adds:

The full list is on the function reference.

One limit that applies to every method: none can be used inside MAP, BYROW or other LAMBDA functions — Google runs those entirely in the calculation engine, which has no access to a cell’s formatting.

Which method should you use?

  Manual tagging 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 style change Re-tag by hand Only with a custom trigger Yes, via built-in refresh
Sum, average, min/max, cross-column No A function each Built in
Available in your other spreadsheets No — paste per file Yes — every sheet on your account
Upkeep Re-tag by hand You own every fix & addition Updates itself
Cost Free Free Free up to 30 cells per formula, then a plan

Manual tagging only makes sense for a one-time count on a small range. A custom function works if you need a single style counted and don’t mind the recalc caveat. Reach for the add-on when styling is part of how you track the sheet and you also need sums, averages or a style check against another column.

Count bold and strikethrough cells without 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