Replace
Explanation of the Excel REPLACE Function¶
The REPLACE function in Excel is used to replace part of a text string based on the position and length of the
substring you want to replace. This is useful for modifying text strings by removing or substituting specific segments.
Syntax:¶
Parameters:¶
- old_text: The original text string from which you want to replace a part.
- start_num: The position (character index) in
old_textwhere you want to begin replacing characters. The first character is indexed as 1. - num_chars: The number of characters to replace in
old_text. - new_text: The text you want to insert in place of the replaced characters.
Example:¶
Suppose cell A1 contains the text HelloWorld.
-
To replace
Result:WorldwithExcel, you can use:HelloExcel -
To replace the first 3 characters with
Result:Hi:HiLowWorld
Use Case:¶
The REPLACE function is particularly helpful when dealing with structured text, such as replacing parts of IDs,
formatting phone numbers, or cleaning up data.
Note:¶
If start_num or num_chars exceed the length of old_text, the function will replace as many characters as it can
starting from start_num. If new_text is left blank (e.g. ""), the specified part of old_text will be deleted.