Google Sheets REPLACE Function: Syntax, Examples & Tips

The REPLACE function is used to substitute part of a text string with another text string, based on specified position and length.
Google Sheets
REPLACE(text, position, length, new_text)

One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.

On this page
  1. Parameters
  2. What is a REPLACE Function?
  3. A Practical Example
  4. REPLACE Formula
  5. Result of the Formula
  6. Why Use REPLACE?
  7. Key Takeaways:
  8. Example use case

Parameters

text:
The original text string that you want to modify.

position:
The position in the text string where you want to start replacing characters. The first character is at position 1.

length:
The number of characters in the text string that you want to replace, starting from the specified position.

new_text:
The text that you want to insert in place of the characters that are being replaced.

What is a REPLACE Function?

The REPLACE function in Google Sheets is a useful tool that allows you to replace part of a text string with another text string. This function is particularly handy when you need to modify or update specific portions of text without having to rewrite the entire string. It can be used for various purposes, such as correcting typos, updating information, or formatting text.

In simpler terms, REPLACE enables you to change a specific part of a text string based on its position and length.

A Practical Example

Imagine you have a list of product codes that need to be updated due to a change in the product line:

Product Codes Table:

ProductCodeDescription
ABC-123Widget A
ABC-456Widget B
ABC-789Widget C

You need to replace the prefix "ABC-" with "XYZ-" for all product codes.

REPLACE Formula

To achieve this, you would use the REPLACE function as follows:

Google Sheets
=REPLACE(A2, 1, 4, "XYZ-")

In this formula:

  • A2 is the cell containing the original ProductCode.
  • 1 is the starting position of the text you want to replace (the first character).
  • 4 is the number of characters to replace (the length of "ABC-").
  • "XYZ-" is the new text that will replace the specified portion.

Result of the Formula

When you apply the REPLACE formula to the Product Codes Table, the output would look like this:

ProductCodeDescription
XYZ-123Widget A
XYZ-456Widget B
XYZ-789Widget C

In this case, the prefix "ABC-" has been successfully replaced with "XYZ-" for all product codes.

Why Use REPLACE?

REPLACE is beneficial because it streamlines the process of modifying text strings in Google Sheets. It allows for quick updates without the need for complex formulas or manual edits. This can save time and reduce errors, especially when dealing with large datasets.

Key Takeaways:

  • REPLACE: A function that replaces part of a text string with another text string based on specified position and length.
  • Efficiency: Enables quick updates to text without rewriting entire strings.
  • Versatility: Useful for correcting errors, updating information, and formatting text.
  • Common Use Cases: Ideal for data cleaning, formatting product codes, and any scenario where text modification is necessary.

REPLACE is an essential function for anyone working with text data in Google Sheets, providing a powerful way to enhance data management and accuracy.

Happy spreadsheeting!

Example use case

You have a list of product codes in Column A and need to update them by removing the last three characters. Use the REPLACE formula to modify the codes in Column B, ensuring accurate inventory tracking without manually editing each entry.

Need more help with Google Sheets formulas?

Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.

Explore all Google Sheets formulas

Browse our complete library of Google Sheets formula guides

Compare your options

Decide with evidence, not a sales pitch.

Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.

  1. 01ChatGPTOpen a balanced comparison prompt in ChatGPT.
  2. 02ClaudeOpen the same research prompt in Claude.
  3. 03PerplexityResearch the comparison with linked web sources.

AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.