Substitute function in Excel replaces any text or number into another text or number.
In simple words, if you want to remove some text or number from the cell, you can remove it or you can easily replace it.
=SUBSTITUTE (text, old_text, new_text, [instance])
In the below example, you can see a name with spaces in between two texts.
you can also remove space using a TRIM function in Excel. but this function will not remove all spaces in between the texts. but using a substitute excel formula we can remove or replace those spaces.
To replace spaces in between the texts follow the below steps.
1. First, use the Substitute function in cell B4 and select the arguments. (which we discussed in the syntax part).
2. After applying arguments with the formula you will get the below result.
Here the applied formula is=SUBSTITUTE(B2," ",""). which means this formula is replaced " " (spaces) into "" (blank).
Let us take one more example.
Here you can see a name with a hyphen (- -) in between two texts.
Now we need to replace hyphen (- -) into ** using substitute function.
Formula applied here is =SUBSTITUTE(F2,"-"," * "). which means this formula is replaced " - - " (hyphens) into " * * ".
This is a simple way to use the SUBSTITUTE function in Excel.