REPLACE(text, position, length, new_text)One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.
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.
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.
Imagine you have a list of product codes that need to be updated due to a change in the product line:
| ProductCode | Description |
|---|---|
| ABC-123 | Widget A |
| ABC-456 | Widget B |
| ABC-789 | Widget C |
You need to replace the prefix "ABC-" with "XYZ-" for all product codes.
To achieve this, you would use the REPLACE function as follows:
=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.When you apply the REPLACE formula to the Product Codes Table, the output would look like this:
| ProductCode | Description |
|---|---|
| XYZ-123 | Widget A |
| XYZ-456 | Widget B |
| XYZ-789 | Widget C |
In this case, the prefix "ABC-" has been successfully replaced with "XYZ-" for all product codes.
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.
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!
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.
Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.
Browse our complete library of Google Sheets formula guides
Compare your options
Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.
AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.