WorksheetFunction.Substitute (Excel)
Substitutes new_text for old_text in a text string. Use Substitute when you want to replace specific text in a text string; use Replace when you want to replace any text that occurs in a specific location in a text string.
Substitute (Arg1, Arg2, ..., Arg4)
Dim strArg1 As String: strArg1 =
Dim strArg2 As String: strArg2 =
Dim strArg3 As String: strArg3 =
Dim strSubstitute As String
strSubstitute = WorksheetFunction.Substitute(Arg1:=strArg1, Arg2:=strArg2, Arg3:=strArg3)
Arguments
Arg1, Arg2, ..., Arg4Arg1 (String) - Text - the text or the reference to a cell containing text for which you want to substitute characters.
Arg2 (String) - Old_text - the text that you want to replace.
Arg3 (String) - New_text - the text that you want to replace old_text with.
Arg4 - Instance_num - specifies which occurrence of old_text you want to replace with new_text. If you specify instance_num, only that instance of old_text is replaced. Otherwise, every occurrence of old_text in text is changed to new_text