REPLACE in Calligra Sheets: Change Text by Position
Learn REPLACE in Calligra Sheets with exact four-argument syntax, fixed-position edits, insertion, worked data and caveats.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Calligra Sheets. How formula examples are checked
REPLACE in Calligra Sheets
Quick answer
REPLACE substitutes a specified number of characters at a fixed position with different text. =REPLACE("2002";3;2;"03") is expected to return 2003. It replaces positions, not occurrences of a searched word; choose SUBSTITUTE when matching old text instead.
Official syntax, arguments and defaults
=REPLACE(text;position;length;new_text)
- text — required original text or text-containing cell reference.
- position — required integer first character position to replace; normal formulas count the first character as 1. Use a valid positive position.
- length — required number of existing characters to remove from
position. Insertion is possible with 0;REPLACE("123456789";5;0;"Q")is expected to insertQwithout deleting anything. - new_text — required replacement string, which can be shorter, longer, or an empty string. Literal strings go in double quotation marks.
- Return — text. This function has exactly four registered arguments in Calligra 26.08.2, with no optional fields/defaults.
Alias note: the 26.08.2 registration gives REPLACEB as alternate name(s) for REPLACE; the older handbook describes B-suffix byte semantics separately. this guide treats them as aliases, not proof of native Unicode/byte equivalence.
Version and evidence: The KDE Sheets function handbook and the pinned Calligra 26.08.2 text function code were checked on 2026-10-11. The code is release-registry/implementation evidence, not native execution proof. The 26.08.2 release announcement is dated 2026-10-08. For a particular installed package, confirm the version and enabled modules.
Formula entry and locale: Formulas begin with =. The English KDE reference uses semicolons to separate parameters, and all examples use English names and plain-ASCII text. Excel English-language reference pages typically show commas instead. Language packs, decimal notation and installed spreadsheet settings can affect formula entry. Paste the formula into a blank cell or use the function assistant to confirm the separator for your installation; do not assume a comma-formatted Excel formula always parses unchanged.
Reproducible worksheet: six example rows
- On a new blank sheet, enter A1 =
Input textand B1 =Formula / result. - Enter each source text in A2 onward as shown in the table. For example, A2 =
abcdefghijk. - Enter the shown formula in B2 onward. Use semicolons as shown in the handbook, or adapt the argument separator only if your local app requires it.
- Compare the displayed result with the expected result. Text
0042should not be coerced to number 42;(empty text)represents the empty string, not literal parentheses.
| A (input text) | B (formula; enter in B2 and fill/adjust for rows) | Expected B result | Why |
|---|---|---|---|
abcdefghijk |
=REPLACE(A2;6;5;"-") |
abcde-k |
Replace fghij with a hyphen |
2002 |
=REPLACE(A3;3;2;"03") |
2003 |
Update final two digits |
123456789 |
=REPLACE(A4;5;3;"Q") |
1234Q89 |
Three characters replaced with one |
123456789 |
=REPLACE(A5;5;0;"Q") |
1234Q56789 |
Insert at position 5 |
INV-2025 |
=REPLACE(A6;5;4;"2026") |
INV-2026 |
Replace four-digit year |
NAME |
=REPLACE(A7;1;4;"NEW") |
NEW |
Replace entire four-character text |
Validation label — independent calculation, not native execution: each expected result was recalculated using a separate Python string manipulation (ASCII-only for these inputs). The results are also consistent with the pinned implementation and relevant KDE unit-test expectations where available. A local Calligra Sheets 26.08.2 application was not available in this run; there are zero observed runtime outputs.
Advanced, realistic examples
Make fixed-width product label changes
For A6 = INV-2025:
=REPLACE(A6;5;4;"2026")
Expected output: INV-2026. This assumes the prefix length remains four characters (including the hyphen). If the input might be INVOICE-2025, do not use position 5; locate the separator dynamically with FIND or use SUBSTITUTE to replace a known term.
Insert without removing characters
For A5 = 123456789, =REPLACE(A5;5;0;"Q") yields 1234Q56789. This is useful for inserting a status marker into consistently formatted ID strings. The pinned KDE source test explicitly includes this example.
Remove characters by replacing them with empty text
With A8 = ABC-123, =REPLACE(A8;4;1;"") is expected to return ABC123. Contrast this with =SUBSTITUTE(A8;"-";""), which removes every hyphen rather than a specific position. Pick the positional version only when the layout is stable.
Errors, limits and troubleshooting
- Off-by-one edits: normal positions start at 1, not 0.
=REPLACE("2002";3;2;"03")targets02, not20. - Replacing the wrong segment: if data uses variable-length prefixes, fixed numeric positions will silently change the wrong characters. Use
FINDorSUBSTITUTEwith a validated delimiter. - Unexpected length changes:
new_textneed not matchlength, so a replacement can expand or shrink the cell value; this is expected. - Invalid negative positions/lengths: older C++ source passes some boundary values to Qt’s string replacement after limited normalization. The handbook does not establish reliable spreadsheet-visible errors for every invalid value. Avoid negative values; do not promise Excel-identical errors without native testing.
- REPLACEB alias: 26.08.2 registers REPLACEB as a second name for the same code while the handbook describes byte positions. Non-ASCII byte behaviour needs native testing, not a separate guide assumed from the name.
- Wrong argument count: all four inputs are required. To remove text, pass
""for new_text rather than omitting argument four.
Cross-software compatibility
Microsoft Excel: English Excel uses REPLACE(old_text,start_num,num_chars,new_text), matching the ordinary four-argument intent but using comma separators in English-language examples. Ordinary ASCII fixed-position edits often transfer, subject to locale and boundary rules. Microsoft has explicit remarks about Unicode compatibility mode and deprecated REPLACEB; do not assume Calligra’s REPLACEB alias handles byte positions identically. Microsoft REPLACE reference.
SUBSTITUTE versus REPLACE: REPLACE changes a position. SUBSTITUTE finds a text value. This difference matters when product codes, names or addresses are not fixed width.
Official reference and verification
- Calligra Sheets — function documentation
- Calligra 26.08.2 text function code
- 26.08.2 release announcement
- SUBSTITUTE
- FIND
- MID
- LEN
Verification status: Official documentation checked; example outcomes were independently reasoned or arithmetically checked where applicable. Not executed in Calligra Sheets.
- No genuine Calligra Sheets screenshots are included; this guide does not use mock application images.