# REPLACE in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/replace/

REPLACE works by position, not by content. You give the start and the number of characters to remove, and it puts new text in their place. To replace a known word wherever it appears, use SUBSTITUTE.

## Syntax

```
REPLACE(text, position, length, new_text)
```

## Arguments

- `text` (string, required: yes): The text to change. A number is treated as text.
- `position` (number, required: yes): Where the replacement starts, counted from 1.
- `length` (number, required: yes): How many characters to remove. 0 inserts without removing.
- `new_text` (string, required: yes): The text put in place of the removed part.

## Examples

The examples use this table, starting in A1:

| Code | Note |
|---|---|
| RO-2024-001 | draft |
| Hello World | greeting |

```
=REPLACE(A2, 4, 4, "2025")
```

Result: `RO-2025-001`

Four characters starting at position 4 (the year) are swapped for 2025. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=REPLACE(A3, 1, 5, "Howdy")
```

Result: `Howdy World`

The first five characters of Hello World become Howdy. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=REPLACE(A3, 6, 0, " big")
```

Result: `Hello big World`

A length of 0 inserts text at position 6 and removes nothing. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=REPLACE(A3, 7, 100, "Sheets")
```

Result: `Hello Sheets`

A length longer than the rest of the text just replaces everything from the position onward. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=REPLACE(12345, 2, 2, "X")
```

Result: `1X45`

A number is read as text: 1, then X, then 45. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- Position 0 returns #VALUE!. Counting starts at 1.
- A negative length returns #VALUE!. Use 0 to insert without removing.
- REPLACE changes one fixed stretch of text. It does not look for a word. Use SUBSTITUTE for that, or REGEXREPLACE for patterns.
- The result is always text, even when the input was a number, so wrap it in VALUE before doing math.

## Compared with Excel

Same syntax as Excel REPLACE.

## Related functions

- [SUBSTITUTE](https://goingstellar.ro/reference/sheets/substitute/)
- [REGEXREPLACE](https://goingstellar.ro/reference/sheets/regexreplace/)
- [LEFT](https://goingstellar.ro/reference/sheets/left/)
- [MID](https://goingstellar.ro/reference/sheets/mid/)
- [LEN](https://goingstellar.ro/reference/sheets/len/)
- [FIND](https://goingstellar.ro/reference/sheets/find/)

## Sources

- [REPLACE (Docs Editors Help)](https://support.google.com/docs/answer/3098247)

