Explain the difference between SUBSTITUTE and REPLACE function in MS-Excel?


The SUBSTITUTE function substitutes one or more instances of old text with the new text in a string.

Syntax: SUBSTITUTE(text, oldText, newText, [instanceNumber])

Example: Let text at A2 be Guru99,Guru99

SUBSTITUTE(A2,”9″,”8″,1) =>Guru89,Guru99

SUBSTITUTE(A2,”9″,”8″,2) =>Guru88,Guru99

SUBSTITUTE(A2,”9″,”9″) =>Guru88,Guru88

The REPLACE function swaps part of the text string with another set of text.

Syntax: REPLACE(oldText, startNumber, NumberCharacters, newText)

Example: Let text at A2 be Guru99

REPLACE(A2,5,1,”00″) =>Guru009


© 2017