contacara

Count text occurrences in an Excel cell

Subtract the length after SUBSTITUTE from the original length. For a multi-character target, divide by its length. The target must be nonempty, and the matches do not overlap. This counts occurrences inside text, rather than the number of matching cells.

Occurrences and matching cells are different

A cell with five mentions contributes five occurrences but only one matching cell. Name the metric before choosing the formula. Literal substring matching can find “arte” inside a longer string; it does not identify words automatically. For rows containing a term, use COUNTIF and matching cells. Keep “affected rows” separate from “total mentions” when both are needed.

Subtract lengths for one character

The literal Italian sample casa, mare, sole contains two commas. Use =LEN(A2)-LEN(SUBSTITUTE(A2,",","")). Each removed comma reduces length by one; the original A2 stays unchanged. You can show the transformed text in a helper column for inspection. A period here is literal, not a regular expression; SUBSTITUTE does not use COUNTIF’s wildcard interpretation.

Divide by the complete target length

For AB-AB-X, removing AB loses four characters, representing two matches. Put the target in D2 and use =(LEN(A2)-LEN(SUBSTITUTE(A2,D2,"")))/LEN(D2) only after checking D2 is nonempty. An empty target is not a meaningful search and creates division by zero. Display an input request instead. When filling down, keep a shared target fixed with $D$2 while the source row advances.

AB-AB-X contains two AB matches. Removing them reduces length from seven to three; four removed characters divided by two gives two occurrences.
The target must be nonempty. This method counts nonoverlapping matches. Open full-size JPG

Set an explicit case rule

SUBSTITUTE distinguishes case. Searching a in aAa finds two; converting both source and target consistently to lowercase gives three. Normalize an analysis copy rather than altering case-sensitive codes. The case converter helps with ordinary text, but a technical archive needs a documented comparison rule. Keep both sample results to show colleagues why the totals differ.

Understand nonoverlapping matching

In aaaa, aa starts in three positions if overlaps are allowed; replacement removes two nonoverlapping matches, so the formula returns two. This matters for repetitive codes. Matching mare also finds that sequence in marea. Adding spaces around a target does not cover punctuation and cell boundaries reliably. Where whole words matter, define tokenization rather than accumulating manual corrections.

Audit rows before adding results

Use a helper result per row and sum only the intended range, retaining stable IDs. Two commas may separate three entries, but an internal comma or trailing separator changes that structural interpretation. Counting the character alone does not parse the format. Keep controls with zero, one and several matches plus an empty row. Distinguish no matches from a formula or source error that prevented evaluation.

Investigate fractions and unexpected totals

A complete-match length difference should be a multiple of the exact target length. A fraction suggests a wrong divisor, changed reference or extra space in only one expression; investigate instead of rounding. Confirm the fourth SUBSTITUTE argument is not restricting replacement to one occurrence. For composed Unicode text, use consistent compatibility settings and units; see emoji and Excel LEN.

Length differences and matches

TextTargetOccurrences
casa, mare, sole,2
AB-AB-XAB2 after dividing by 2
aAaa2, case-sensitive
aaaaaa2, nonoverlapping
Original literal samples; divide removed characters by the nonempty target length.

Sources and checks

Open the tool