1. Home
  2. Functions
  3. Text
  4. SUBSTITUTE

SUBSTITUTE function

Replaces existing text with new text, everywhere or only in one occurrence.

Syntax

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

Arguments

ArgumentRequiredDescription
textRequiredThe text to change
old_textRequiredThe text to replace
new_textRequiredThe replacement
instance_numOptionalWhich 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 "Cost Data"
=SUBSTITUTE("Quarter 1, 2008", "1", "2", 1)Result "Quarter 2, 2008"
=SUBSTITUTE("Quarter 1, 2011", "1", "2", 3)Result "Quarter 1, 2012"

Every formula, right in your browser

SheetsBat calculates 536 functions, with charts, pivot tables and live collaboration. Free to start.