Syntax
=SUBSTITUTE(text, old_text, new_text, [instance_num])Arguments
| Argument | Required | Description |
|---|---|---|
text | Required | The text to change |
old_text | Required | The text to replace |
new_text | Required | The replacement |
instance_num | Optional | Which occurrence to replace (all when left out) |
How to use SUBSTITUTE
SUBSTITUTE takes 3 required arguments and 1 optional argument. Type =SUBSTITUTE( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=SUBSTITUTE("Sales Data", "Sales", "Cost")Result =SUBSTITUTE("Quarter 1, 2008", "1", "2", 1)Result =SUBSTITUTE("Quarter 1, 2011", "1", "2", 3)Result Related text functions
- RIGHTBSame as RIGHT, counting bytes; without a double byte language set as default each character counts as one byte.
- SEARCHReturns the position of one text inside another, ignoring case. Accepts the wildcards ? and *.
- SEARCHBSame as SEARCH, counting bytes; without a double byte language set as default each character counts as one byte.
- SPLITSplits text at a delimiter into a row of cells.
- TReturns the value if it is text, otherwise empty text.
- TEXTFormats a number as text with a number format code, like "$#,##0.00" or "yyyy-mm-dd".
- TEXTAFTERReturns the text that comes after a delimiter.
- TEXTBEFOREReturns the text that comes before a delimiter.
- TEXTJOINJoins texts and ranges with a delimiter between them, optionally skipping empty values.