tech on the net

MS Excel: REPLACE Function (WS)

In Microsoft Excel, the REPLACE function replaces a sequence of characters in a string with another set of characters. Please note that the VBA version of the REPLACE function has different syntax.

Syntax

The syntax for the REPLACE function is:

REPLACE( old_text, start, number_of_chars, new_text )

old_text is the original string value.

start is the position in old_text to begin replacing characters.

number_of_chars is the number of characters to replace in old_text.

new_text is the replacement set of characters

Applies To

Type of Function

Worksheet Function Example

Let's take a look at an example to see how you would use the REPLACE function in a worksheet:

Microsoft Excel

Based on the Excel spreadsheet above, the REPLACE function would return the following:

=REPLACE(A1, 1, 5, "Beta") would return "Betabet Soup"
=REPLACE(A2, 5, 2, "1234") would return "tech1234thenet.com"
=REPLACE("apples", 2, 5, "te") would return "ate"