Contact

SUBSTITUTE Function in ONLYOFFICE Spreadsheet Editor: Formula and Examples

Text and Data Beginner ONLYOFFICE Spreadsheet Editor

Replace matching text rather than character positions.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

SUBSTITUTE replaces matching text. If A5 contains INV|2026|0412, =SUBSTITUTE(A5,"|","-") gives INV-2026-0412. Omitting the fourth argument replaces every match; specifying an occurrence number selects one match.

Availability and version history

  • Introduced: The original introduction version and date are not established by the checked references.
  • Availability: Documented in current ONLYOFFICE Spreadsheet Editor help; no final supported-version endpoint is established.
  • Scope: Desktop and Docs release separately. Older builds, mobile clients, localized parsing and imported-workbook parity remain separately unverified.
  • Checked: October 14, 2026, against the official SUBSTITUTE reference, vendor illustration and pinned calculation source. Examples were independently calculated; these formulas were not executed in a native application.

Syntax: all matches or a selected occurrence

SUBSTITUTE(text, old_text, new_text, [instance_num])

The source text, text to find and replacement text are required. instance_num is optional; the official entry explicitly says omission replaces all occurrences. It is an occurrence number, not a character position or the number of characters to remove.

The brief help does not explain case matching. The pinned calculation source escapes old_text before constructing a case-sensitive global match and selects the requested occurrence from left to right. The literal and mixed-case examples below follow that source contract; they are not native application observations. A *, ? or period in old_text is not treated as a pattern by that escaped matching path.

Preserve the original eight text records

Create Substitutions with space through G9. Put Source text in A1 and enter:

Cell Text input
A2 ORD-4821-ON
A3 PO-1047-Toronto
A4 red-red-red
A5 INV|2026|0412
A6 INV-2025-0412
A7 sales@Example.com
A8 ABC-xyz-ABC
A9 PO-0008-WEST

Type A5 with actual vertical bars: INV|2026|0412. Keep all eight inputs unchanged. Enter the following individual formulas in B2:B7:

B2: =SUBSTITUTE(A5,"|","-")
B3: =SUBSTITUTE(A5,"|","-",1)
B4: =SUBSTITUTE(A4,"red","blue")
B5: =SUBSTITUTE(A4,"red","blue",2)
B6: =SUBSTITUTE(A4,"red","blue",3)
B7: =SUBSTITUTE(A8,"ABC","ID")

Enter =LEN(B2) in C2 and fill through C7.

Row Expected B Expected C
2 INV-2026-0412 13
3 INV-2026|0412 13
4 blue-blue-blue 14
5 red-blue-red 12
6 red-red-blue 12
7 ID-xyz-ID 9

Longer replacement text increases the output length once for each replaced match. Changing only the second match in B5 is different from replacing all three matches in B4.

In E2 enter =SUBSTITUTE(SUBSTITUTE(A5,"|","-"),"INV","ORD"); the original chained example gives ORD-2026-0412. In E3 enter =SUBSTITUTE(A7,"Example.com","example.ca"); the result is sales@example.ca. These specific transformations do not validate an identifier or parse arbitrary email addresses.

Check the official illustration

On VendorSubstitute, enter Online Office is a cloud business service in A1 and portal in A2. Enter =SUBSTITUTE(A1,"Office",A2) in A4. The expected Online portal is a cloud business service matches the actual vendor illustration.

To keep a changed-input comparison, duplicate this worksheet as ChangedVendor. Replace A1 with Office Office and put =SUBSTITUTE(A1,"Office",A2,2) in B4. A4 becomes portal portal; B4 becomes Office portal. The all-occurrence and selected-occurrence formulas now visibly differ.

Case and literal-pattern controls

Create LiteralMatches with A1:D4 and put these source strings in A2:A4:

  • A2: red-RED-red
  • A3: A*B?C.A*
  • A4: red-red-red

Enter each formula separately:

B2: =SUBSTITUTE(A2,"red","blue")
C2: =SUBSTITUTE(A2,"RED","blue")
D2: =EXACT(B2,C2)
B3: =SUBSTITUTE(A3,"*","-")
C3: =SUBSTITUTE(A3,"?","!")
D3: =SUBSTITUTE(A3,".","/")
B4: =SUBSTITUTE(A4,"red","",2)
C4: =LEN(B4)

The source-based expectations are B2 blue-RED-blue, C2 red-blue-red, D2 FALSE; B3 A-B?C.A-, C3 A*B!C.A*, D3 A*B?C/A*; B4 red--red, C4 8. Removing the middle word leaves both separators. It does not automatically clean the doubled hyphen.

Why the order of cleanup steps matters

Create CleanupOrder with A1:F3. Put CA--2026--RED in A2 and EU--009--GRN in A3. Enter B2:F2 and fill through row 3:

B2: =SUBSTITUTE(A2,"--","-")
C2: =SUBSTITUTE(B2,"-","/")
D2: =SUBSTITUTE(A2,"-","/")
E2: =SUBSTITUTE(D2,"--","-")
F2: =EXACT(C2,E2)

C2:C3 contain CA/2026/RED and EU/009/GRN. E2:E3 contain CA//2026//RED and EU//009//GRN; F2:F3 are FALSE. Once the hyphens have become slashes, a later operation looking for doubled hyphens cannot remove them.

Keep this worksheet separate from the original records. A useful-looking cleaned label can still collide with a different original label; replacement is not a uniqueness check.

Errors and remaining boundaries

Omit instance_num to request all matches; do not substitute an explicit zero for omission. In the pinned source, an explicitly supplied nonpositive occurrence is rejected after flooring its numeric value. The empty-search branch is handled separately, so do not turn that narrow observation into a universal error-order claim.

The source also returns the original string when old_text is empty. Fractional occurrence handling, blank/numeric coercion, Unicode normalization and extreme lengths need version-specific validation before a migration relies on them. This guide’s practical cases use text and positive integer occurrences.

REPLACE handles positions rather than matches. REGEXREPLACE is the separate pattern-replacement function. Adapt English names and comma separators to the workbook’s locale, and preserve the original text while testing changes.