SUBSTITUTE Function
The Excel SUBSTITUTE function replaces matching text by content, either for every occurrence or for one selected occurrence.
| Excel SUBSTITUTE Function | ||||||||
| SUBSTITUTE replaces matching text everywhere or at one selected occurrence. | ||||||||
| Source cases, editable | SUBSTITUTE examples | |||||||
| Scenario | Source text | Old text | New text | Instance | Example | Formula syntax | Result | |
| Replace all | A-B-C | - | / | Replace all | =SUBSTITUTE(B12,C12,D12) | A/B/C | ||
| Second only | A-B-C | - | / | 2 | Second only | =SUBSTITUTE(B13,C13,D13,E13) | A-B/C | |
| Remove dots | Q3.2026.Plan | . | Remove dots | =SUBSTITUTE(B14,C14,D14) | Q32026Plan | |||
| Case sensitive | North NORTH | North | South | Case sensitive | =SUBSTITUTE(B15,C15,D15) | South NORTH | ||
| No match | Workbook | bookx | sheet | No match | =SUBSTITUTE(B16,C16,D16) | Workbook | ||
| How SUBSTITUTE behaves | ||||||||
| Omitting instance_num replaces every exact match of old_text. | ||||||||
| Providing instance_num replaces only that occurrence and leaves the others unchanged. | ||||||||
| Matching is case-sensitive; if no exact match exists, the source text is returned unchanged. | ||||||||
| Reliability checks | ||||||||
| Every hyphen in A-B-C is replaced with a slash | OK | |||||||
| Only the second hyphen changes in the selected case | OK | |||||||
Overview
The Excel SUBSTITUTE function performs find-and-replace by matching content. It replaces every exact occurrence by default or only one occurrence when instance_num is supplied.
Quick reference
Syntax: =SUBSTITUTE(text, old_text, new_text, [instance_num])
Returns: The processed text after the requested replacement. (text)
Arguments:
text(required) — The source text to process.old_text(required) — The exact case-sensitive text to find.new_text(required) — The replacement text; use an empty string to remove matches.instance_num(optional) — The one-based occurrence to replace; when omitted, all occurrences are replaced.
The bracketed instance_num argument is optional. Omit it to replace every exact, case-sensitive match, or supply a positive occurrence number to replace only that instance.
Common uses
- Standardize delimiters in identifiers or imported text.
- Remove known unwanted characters.
- Replace one selected occurrence while preserving others.
- Clean line breaks or fixed markers from text.
Calculations
SUBSTITUTE scans the source string for exact matches to old_text. Without instance_num, every match is replaced. With a positive occurrence number, only that match changes.
Matching is case-sensitive and does not support wildcards. If the requested text or occurrence is not found, the original text is returned unchanged.
SUBSTITUTE works by content rather than character position. Use REPLACE when the starting position and number of characters define the edit.
Function behavior
Situation | Behavior |
|---|---|
Omitted | Replaces every occurrence. |
Positive | Replaces only that one-based occurrence. |
No match | Returns the original text. |
Occurrence exceeds matches | Returns the original text unchanged. |
Letter case | Matching is case-sensitive. |
Wildcards | Not supported. |
Empty | Removes the matched content. |
Multiple different replacements | Requires nested SUBSTITUTE calls or another method. |
Common errors
Confusing content and position replacement
What happens:
The formula targets a string when the edit is actually defined by character position, or vice versa.
Better approach:
Use SUBSTITUTE for matching content and REPLACE for a known position and length.
Expecting case-insensitive matching
What happens:
Variants with different capitalization remain unchanged.
Better approach:
Normalize case first or handle the required variants explicitly.
Using wildcards
What happens:
Asterisks and question marks are treated as literal characters.
Better approach:
Use a pattern-capable function such as REGEXREPLACE where supported.
Example
Example 1 — Replace Every Delimiter
=SUBSTITUTE(B12,C12,D12)
Replacing every hyphen in A-B-C with / returns A/B/C.
Example 2 — Replace One Occurrence
=SUBSTITUTE(B13,C13,D13,E13)
With instance_num set to 2, only the second hyphen changes and the result is A-B/C.
Example 3 — Remove Matching Text
=SUBSTITUTE(A1,"#","")
An empty new_text removes every hash symbol.
Example workbook
The workbook contains a SUBSTITUTE Example sheet with five editable source strings, search text, replacement text, and optional occurrence numbers. Live formulas demonstrate replace-all, one occurrence, removal, and no-match behavior, while two checks confirm the hyphen examples. A Notes sheet explains case sensitivity and alternatives.
Key takeaway
Omit instance_num to replace every exact match, or provide a one-based occurrence number when only one match should change.