Replace replaces part of a text string, based on the number of characters you specify, with a different text string.
Syntax
The syntax for the REPLACE function in Microsoft Excel is:
=REPLACE( old_text, start_num, num_chars, new_text )
Parameters or Arguments
old_text
The original string value.
start_num
The position in old_text to begin replacing characters.
num_chars
The number of characters to replace in old_text.
new_text
The replacement set of characters.
Replace Function Examples
Column B of the following spreadsheet shows two examples of the Excel Replace Function.
Formulas:
Results:
Common Error
You get an error from the Excel Replace function if
- The supplied start_num argument is negative or is a non-numeric value
- The supplied num_chars argument is negative or is non-numeric.
The Excel Replace function is designed for use with text strings and returns a text string. Therefore, if you attempt to use the replace function with a date, time or a number, you may get unexpected results.
1 thought on “Replace() Function”
Comments are closed.