ReferenceFunctionsText Functions
SUBSTITUTE
SUBSTITUTE: Replaces matching text within a string.
Summary
SUBSTITUTE can replace all occurrences or only a specific instance.
Remarks
- Matching is case-sensitive.
- If
old_textis empty, the original text is returned unchanged. - With
instance_num, only that 1-based occurrence is replaced. - Non-positive
instance_numreturns#VALUE!.
Examples
Replace all matches
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
x-b-x
Replace only second match
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
2024-01-FY24
Related functions
FAQ
Is SUBSTITUTE case-sensitive?
Yes. It matches old_text with exact case and replaces either all or the requested instance.
Runtime metadata
Category
Text
Signature
SUBSTITUTE(arg1, arg2, ... argN: Any)This function accepts a repeating argument pattern (min args: 3).
Arity
min 3, max variadic
Arguments
arg1Any · Scalar
Caps
PURE
Source