# REPLACE Function

> Replace characters at a position in text with the REPLACE formula function of TX Sheet Control: start, length, inserting, appending and the #VALUE! error.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > REPLACE Function
- **235 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/replace/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/replace/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/replace/llms-full.txt

---

Replace part of a text, given by its position. `old_text` is the text, `start_num` the position of the first character to replace, from 1, `num_chars` the number of characters to replace and `new_text` the text to insert. A `num_chars` of 0 inserts `new_text` without removing anything, and a `start_num` after the end appends it. A `start_num` less than 1 or a negative `num_chars` returns `#VALUE!`.

### Syntax

```text
REPLACE(old_text, start_num, num_chars, new_text)
```

Category: Text. Minimum arguments: 4. Maximum arguments: 4.

Available for supported offline calculation.

### Examples

```text
=REPLACE("abcd",2,2,"XY")
```

The formula returns aXYd.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [REGISTER.ID Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/register-id/llms-full.txt)
- **Next:** [REPLACEB Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/replaceb/llms-full.txt)
