← All how-to recipes

How to count items in a comma-separated cell

✓ Verified in LibreOffice 25.8.7.3

How many tags, emails, or entries live in one delimited cell.

The formula

AppFormulaNotes
Excel=LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1Counts separators and adds one. 365 alternative: =COLUMNS(TEXTSPLIT(A2,",")).
Google Sheets=LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1Identical; or =COUNTA(SPLIT(A2,",")).
LibreOffice Calc=LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1Identical.

How it works

Removing the commas shortens the text by exactly the number of separators; items are always one more than that: "red,green,blue" loses 2 characters → 3 items. It's the same LEN/SUBSTITUTE trick as word counting, pointed at a different delimiter. Guard the empty-cell case with IF(A2="",0,...) — an empty cell would otherwise count as 1 — and TRIM first if the data has stray spaces around separators you also want to count on.

Verified, not just documented

We ran =LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1 in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 3 — exactly the expected result. Every formula here is confirmed by actually executing it.