REPLACE Function

REPLACE Function

REPLACE Function

Replaces part of a text string based on character position.

ExcelClash Team
PUBLISHED

Summary

The Excel REPLACE function changes part of a text string based on character position. You tell Excel where to start, how many characters to replace, and what text to insert instead.

That makes REPLACE different from SUBSTITUTE. SUBSTITUTE looks for matching text content, while REPLACE works by position. If you know the exact part of the string to overwrite, REPLACE is usually the better choice.

Purpose

Replace text at a known position

Overwrites a section of text based on where it starts and how long it is.

Return Value

A modified text string

Returns the full string with one section replaced.

Syntax

=REPLACE(old_text, start_num, num_chars, new_text)

old_text is the original string. start_num is the first character position to replace. num_chars is how many characters to remove. new_text is what you want to insert in their place.

Arguments

  • old_text - [Required] The original text string or cell reference.
  • start_num - [Required] The position where the replacement begins.
  • num_chars - [Required] The number of characters to remove from the original text.
  • new_text - [Required] The replacement text to insert.

REPLACE vs Other Functions

REPLACE and SUBSTITUTE both modify text, but they solve different problems. Use REPLACE when you know the position. Use SUBSTITUTE when you know the text you want to change.

Function Targets By Use When
REPLACE Character position You know where the change starts
SUBSTITUTE Text content You know what text to replace
FIND - You need to calculate the replacement position

Using REPLACE

REPLACE is useful for masking values, updating fixed parts of a code, or inserting text at a known point. If the same segment always appears in the same position, the formula can stay simple and direct.

REPLACE also has two helpful patterns. If new_text is an empty string, the selected characters are deleted. If num_chars is 0, REPLACE inserts text without removing anything.

  • Use REPLACE when you know the exact character position of the change.
  • Set num_chars to 0 when you want to insert text without deleting existing characters.
  • Use FIND with REPLACE when the start position changes from row to row.

Example 1 - Updating a Year in a Label

If the year always starts in the same place, REPLACE can update it with a fixed position and length. There is no need to search for the year text itself.

=REPLACE(A2, 7, 4, "2024")
// "Excel-2021" -> "Excel-2024"
Check Answer
Challenge #1
Target: Sheet1!F1
Update a Year in a Label

In cell F1, use REPLACE to change "2021" to "2024" in A2 ("Excel-2021"). The year starts at position 7 and is 4 characters long.

Example 2 - Masking the Start of an ID

REPLACE is often used to hide part of an ID or account number. The original data remains untouched in the source cell, while the formula returns a safer display version.

=REPLACE(A3, 1, 3, "***")
// "123-456" -> "***-456"
Check Answer
Challenge #2
Target: Sheet1!F2
Mask the Start of an ID

In cell F2, use REPLACE on A3 ("123-456") to replace the first 3 characters with "***".

Example 3 - Swapping a Prefix

If the prefix length is known, REPLACE can swap it out directly. This works well when a code format changes but the rest of the string should stay as it is.

=REPLACE(A2, 1, 2, "ID")
// Replaces the first 2 characters with "ID"
Check Answer
Challenge #3
Target: Sheet1!F3
Swap a Prefix

In cell F3, use REPLACE on A2 to change the prefix to "ID". The prefix is the first 2 characters.

Example 4 - Dynamic Replacement After a Delimiter

When the text before the target section may vary in length, use FIND to calculate the start position first. That makes the replacement dynamic instead of hardcoded.

=REPLACE(A2, FIND("-",A2)+1, 4, "XXXX")
// "Excel-2021" -> "Excel-XXXX"
Check Answer
Challenge #4
Target: Sheet1!F4
Dynamic Replacement After a Delimiter

In cell F4, use FIND to locate the hyphen in A2, then use REPLACE to mask the 4 characters after it.

REPLACE always returns text. If the source value is numeric, Excel first treats it as text for the replacement. That matters if the result needs to be used in later calculations.

Conclusion Recap

  • Summary: REPLACE changes text based on character position.
  • Syntax: =REPLACE(old_text, start_num, num_chars, new_text).
  • Key point: REPLACE works by position, not by matching text content.
  • Practical usage: Masking, fixed-position updates, and position-based text edits.
  • Best pattern: Combine REPLACE with FIND when the replacement position is not fixed.
Tactical Arena
Select Scenario:
Share REPLACE Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.