← All comparisons

SUBSTITUTE vs REPLACE: by text or by position

They sound like synonyms; they're opposites in how they aim. SUBSTITUTE finds TEXT you know ("replace every dash") — REPLACE overwrites a POSITION you know ("replace characters 4-6, whatever they are"). Picking the wrong one is why the other one's arguments never seem to make sense.

The differences at a glance

SUBSTITUTEREPLACE
You specifyThe old text and its replacementStart position, length, and the new text
OccurrencesAll by default; the 4th argument picks the nthExactly one position
Case sensitivityCase-sensitiveN/A — position-based
Typical jobsStrip symbols, swap separators, clean importsMask digits, fix fixed-width codes, insert into IDs
CompatibilityUniversalUniversal (every version of all three apps we test)

Which should you use?

Compatibility (from executed tests)

Both execute identically in every version of Excel, Google Sheets, and LibreOffice we test. One cross-app note: Google Sheets' REGEXREPLACE covers both jobs (and more) but is Sheets-only — formulas using it break on export.

Example formulas

SUBSTITUTE (by text)=SUBSTITUTE(A2,"-","/")
REPLACE (by position)=REPLACE(A2,1,12,"************")
Insert without deleting (length 0)=REPLACE(A2,4,0,"-")

Full per-version details on each function page: SUBSTITUTE · REPLACE.