REPLACE Function in Apple Numbers: Syntax, Examples and Troubleshooting
Modify fixed-width segments of text identifiers with position-based Apple Numbers formulas.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Apple Numbers. How formula examples are checked
REPLACE function in Apple Numbers
Quick answer
REPLACE changes characters by position, not by searching for a particular word. For example =REPLACE("CA-2048-R1",4,4,"XXXX") has the expected result CA-XXXX-R1. Use SUBSTITUTE when the goal is to replace occurrences of a matching text string rather than a fixed-position segment.
When to use REPLACE
Replace a fixed number of characters beginning at a specified character position. First check whether the input needs to be treated as text so that leading zeroes, spaces or punctuation are not silently changed during import. Start with the sample table below, verify its result, and only then adapt your formula to production records.
Official syntax and argument order
=REPLACE(source-string, start-pos, replace-length, new-string)
| Argument | Requirement and meaning |
|---|---|
source-string |
Required value whose characters will be replaced; Apple permits any value. |
start-pos |
Required number for the 1-based starting position; must be at least 1. |
replace-length |
Required number of characters to remove; must be at least 1 according to Apple. |
new-string |
Required replacement value; its length may differ from the removed text. |
The syntax and parameter order above are taken from Apple’s REPLACE reference (consulted 2026-10-11). Arguments shown as … are optional extra values, not punctuation to type literally. No first-supported Numbers app version was established by the official reference.
Reproducible dataset
Create a Numbers table named Code Cleanup, with the following values formatted as Text. The identifiers have a two-character region prefix, a hyphen, four digits, a hyphen and a two-character suffix.
| Row | A — Source code | B — Expected masked code |
|---|---|---|
| 2 | CA-2048-R1 |
CA-XXXX-R1 |
| 3 | US-7312-R2 |
US-XXXX-R2 |
| 4 | UK-0097-R3 |
UK-XXXX-R3 |
| 5 | CA-6005-R1 |
CA-XXXX-R1 |
Worked example, step by step
- Select B2 in the same table. Type
=REPLACE(A2,4,4,"XXXX"). - The fourth character of
CA-2048-R1is2, and characters 4–7 are2048. - Expected B2:
CA-XXXX-R1. The prefixCA-and suffix-R1remain unchanged. - Fill the formula through B5. The expected outputs are shown in the last column of the table.
A second check, =REPLACE("CA-2048-R1",3,1,"_"), is expected to return CA_2048-R1. Replacing one character does not mean replacing every hyphen.
Advanced application
Find the start of a variable-position field
For identifiers whose prefix might be two or three characters, do not hard-code start position 4. With A2 = CA-2048-R1, the formula
=REPLACE(A2,FIND("-",A2)+1,4,"XXXX")
uses FIND to locate the first hyphen (at position 3) and begins replacement at 4. The expected result is CA-XXXX-R1. For CAN-2048-R1, FIND returns 4 and the same formula yields CAN-XXXX-R1. This assumes the next field always occupies exactly four characters; validate variable-length identifiers before bulk application.
Typical errors, edge cases and troubleshooting
- Off-by-one positions: Numbers positions start at 1, not zero. Test the formula on one known record before filling a column.
- Length zero is not documented as valid: Apple’s reference requires
replace-length >= 1. Do not apply an Excel-style zero-length insertion workaround without native testing. - Start after end of text: Apple documents that when
start-posexceeds the string length,new-stringis appended. This may hide bad positions; compare source lengths withLENbefore large edits. - Unexpected removed characters: check both
start-posandreplace-length; a four-character replacement beginning at the third character removes positions 3–6, not 4–7. - Replacement token too short/long: Apple allows new text of a different length; output width is not preserved automatically.
- Imported data: ensure codes are formatted as text if leading zeroes or punctuation are important.
Excel, Google Sheets and other spreadsheet alternatives
Excel, Google Sheets and LibreOffice Calc have similarly named REPLACE functions, but do not assume edge-case handling for zero-length replacement or imported values is identical. In Numbers, Apple’s published replace-length requirement is at least 1. For replacement by matching text rather than by position, the related Numbers function is SUBSTITUTE (a separately documented function); for pattern processing, REGEX.EXTRACT is documented but does not itself perform the same fixed-position replacement.
Numbers version, platform and regional considerations
This page follows Apple’s English Formulas and Functions Help 15.4 documentation, checked 2026-10-11. That is a documentation version, not proof of the first Numbers release that supported this function. Apple describes its Functions Browser for Numbers on Mac, iPhone, iPad and iCloud.com; the cited function reference does not specify a separate minimum installed version for this function or certify that all device editions behave identically. Mac, iPhone, iPad and web execution were not tested here.
- In the example table, a formula placed in the same table can use
A2,B2orA2:A6. For another Numbers table, the explicit form can beProducts::A2orSheet 2::Products::A2where disambiguation is needed. Use the built-in reference picker to avoid errors. - Apple’s English documentation separates arguments with commas. With a comma decimal separator configuration, Apple instructs you to use semicolons as function argument separators when typing by hand, such as
=REPLACE(A2;4;4;"XXXX"). This does not alter punctuation inside quoted text. - The examples are illustrative content, not screenshots and not proof of live application execution.
Related published-source tutorials
Internal related-guide URLs should be confirmed in the final site build; the source documentation is linked above.
Official reference and verification
- Apple Numbers — function documentation
- Apple Functions Overview
- Apple: Refer to cells in formulas
- Apple Formulas and Functions Help
Verification status: Official documentation checked; example outcomes were independently reasoned or arithmetically checked where applicable. Not executed in Apple Numbers.
- No genuine Apple Numbers screenshots are included; this guide does not use mock application images.