How to Use the REPLACE, REPLACEBs Function in Excel

Replace Text in Excel and Google Sheets

In both Microsoft Excel and Google Sheets, the REPLACE function allows you to substitute a specific portion of a text string with a different text. This function is particularly handy for modifying text within a cell or removing unwanted characters from a string.

Basic Syntax:

The syntax for the REPLACE function is consistent across both Excel and Google Sheets:

Argument Description
old_text The original text where you intend to make a replacement.
start_num The position in old_text where the replacement will begin.
num_chars The number of characters in old_text to be replaced.
new_text The text that will be inserted in place of the specified segment of old_text.

Examples:

Here are some examples to demonstrate how the REPLACE function can be applied in practical scenarios.

Example 1:

Imagine you have the phrase “Good morning, World!” in cell A1 and you wish to replace “morning” with “afternoon”. Use the formula:

=REPLACE(A1, 6, 7, "afternoon")

This formula will substitute “morning” with “afternoon” starting at the 6th character.

Example 2:

Consider a phone number formatted as “(555) 123-4567”. If you want to remove the brackets and hyphen to format it as “5551234567”, employ the following:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")",""),"-","")

This series of SUBSTITUTE functions effectively removes the brackets and hyphen from the phone number.

These examples highlight the flexibility and utility of the REPLACE function in editing text within Excel and Google Sheets.

More information: https://support.microsoft.com/en-us/office/replace-replaceb-functions-8d799074-2425-4a8a-84bc-82472868878a

Other functions
Returns an array of text values from any specified range
Changes full-width (double-byte) English letters or katakana within a character string to half-width (single-byte) characters
Converts a number to text, using the ß (baht) currency format
Returns the character specified by the code number
Removes all nonprintable characters from text
Returns a numeric code for the first character in a text string
Combines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments
Joins several text items into one text item
Changes half-width (single-byte) English letters or katakana within a character string to full-width (double-byte) characters
Converts a number to text, using the $ (dollar) currency format
Checks to see if two text values are identical
Finds one text value within another (case-sensitive)
Formats a number as text with a fixed number of decimals
Changes half-width (single-byte) characters within a string to full-width (double-byte) characters
Returns the leftmost characters from a text value
Returns the number of characters in a text string
Converts text to lowercase
Returns a specific number of characters from a text string starting at the position you specify
Converts text to number in a locale-independent manner
Extracts the phonetic (furigana) characters from a text string
Capitalizes the first letter in each word of a text value
Repeats text a given number of times
Returns the rightmost characters from a text value
Finds one text value within another (not case-sensitive)
Substitutes new text for old text in a text string
Converts its arguments to text
Formats a number and converts it to text
Combines the text from multiple ranges and/or strings, and includes a delimiter you specify between each text value that will be combined If the delimiter is an empty text string, this function will effectively concatenate the ranges
Removes spaces from text
Returns the Unicode character that is references by the given numeric value
Returns the number (code point) that corresponds to the first character of the text
Converts text to uppercase
Converts a text argument to a number
Returns text from any specified value