REPLACE Function (OpenOffice Calc)
Learn the REPLACE function in Apache OpenOffice Calc: Replaces characters within a text string with a different text string.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Availability and version history
- Introduced: Documented by Apache OpenOffice 4.1.16; original introduction not established.
- Availability: Supported in Apache OpenOffice 4.1.16, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
REPLACE removes a specified number of characters at a one-based position and inserts new text there. It works by position, not by finding a matching word. The inserted text can be shorter or longer than the removed segment, so the total string length can change.
Syntax and arguments
=REPLACE(text; start; count; new_text)
All four arguments are required. text is the original string, start the one-based insertion position, count the number of characters removed, and new_text the replacement. Use start>=1 and count>=0. The 4.1.16 interpreter approximately floors numeric start/count, checks internal bounds, then clamps an ordinary oversized position to the end of the string. English function names and semicolon argument separators are used here.
Reproducible examples
| Formula | Expected result |
|---|---|
=REPLACE("abcdef";2;3;"XYZ") |
"aXYZef" |
=REPLACE("abcdef";2;0;"-") |
"a-bcdef" |
=REPLACE("abcdef";2;3;"") |
"aef" |
=REPLACE("abc";4;0;"!") |
"abc!" |
=REPLACE("abc";99;2;"!") |
"abc!" |
=REPLACE("abc";2;99;"X") |
"aX" |
The first formula preserves the original guide’s worked example. Its historical comparable LibreOffice 25.2 check was not an OpenOffice test. New results are independently checked reference expectations; no fresh native or GUI test is claimed. Here "" denotes zero-length text.
Practical worksheet: update a fixed-position code field
Enter AB-0042-EU, CD-1050-US and EF-0007-UK in A2:A4. In B2 enter =REPLACE(A2;4;4;"XXXX") and fill down. Expected strings are AB-XXXX-EU, CD-XXXX-US and EF-XXXX-UK. The four-character field begins at position 4 and its separators remain intact.
This transformation assumes a fixed layout. A malformed record with an extra leading character would have different positions and could change the wrong text. Validate the layout first. Replacing visible characters is not secure deletion: the original values in column A, file history and other copies may still exist.
Advanced applications
Insert rather than remove. A count of zero inserts new text. =REPLACE("AB0042";3;0;"-") returns AB-0042. This is useful for a known fixed format, without changing the underlying digits.
Remove a known section. With AB-0042-EU in A2, =REPLACE(A2;3;5;"") returns AB-EU by deleting the first hyphen and the four-digit field. Check the positions explicitly rather than inferring them from how wide the text looks on screen.
Combine a found boundary with replacement. With North-West in A2, =REPLACE(A2;FIND("-";A2);1;"/") returns North/West. FIND locates the first literal hyphen; REPLACE then changes one character there. A missing hyphen fails at the FIND step and should be handled as an input issue.
Errors, edge cases and troubleshooting
Start zero or negative count is invalid. For ordinary valid positive positions beyond the end, the inspected source appends new text rather than padding the gap with spaces. A removal count larger than the available suffix removes only that suffix. The callback still imposes an internal numeric/string bound, so this is not a promise that arbitrarily huge positions are accepted.
The function does not search for every occurrence of a substring. Use SUBSTITUTE when the rule is to replace matching text rather than a fixed position. Conversely, do not use SUBSTITUTE when the same text appears elsewhere and only one known field should change.
Result text can exceed the original length and can reach the application’s string limit. No extreme-size native test is claimed. Numeric arguments converted to text may not retain their custom display formats or leading zeros. Positions in these ASCII examples are not certified byte or grapheme boundaries for multilingual strings. Keep the source column and review a sample of transformed rows before adopting a fixed-layout change.
Related functions
Documentation and verification
See the Apache OpenOffice REPLACE reference, 4.1.16 text-function help, and versioned interpreter. The official source snapshots were retrieved on October 13, 2026 and re-read for this guide; no new retrieval date is implied. Source inspection and reference calculations do not certify native encoding, locale or extreme-input behavior. First introduction and final functioning version remain unestablished; the lifecycle section identifies documented support.