How to Substitute Multiple Characters in Excel: 7 Methods

 

Method 1 – Using the SUBSTITUTE Function to Substitute Multiple Characters

Below is a dataset of Microsoft Word version names. We want to substitute “Word” with “Excel”. We use the SUBSTITUTE function to do so.

Use the SUBSTITUTE Function to Substitute Multiple Characters

Step 1:

  • Enter the following formula in a cell:
=SUBSTITUTE(B5,"Word","Excel",1)

Use the SUBSTITUTE Function to Substitute Multiple Characters

Step 2:

  • Press Enter.

Use the SUBSTITUTE Function to Substitute Multiple Characters

Step 3:

  • Repeat the previous steps for the other two criteria.

Use the SUBSTITUTE Function to Substitute Multiple Characters

You will get values for all subsequent fields.

Note. The SUBSTITUTE function is case-sensitive. As shown below, the values could not be found for words written in lowercase. So, there was no substitution.

Use the SUBSTITUTE Function to Substitute Multiple Characters


Method 2 – Nesting the SUBSTITUTE Function to Substitute Multiple Characters

Below, we will substitute the three codes with full names.

Nest the SUBSTITUTE Function to Substitute Multiple Characters

Step 1:

  • Enter the following formula in cell C5:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B5,"art.","article"),"amend.","amendments"),"cl.","clause")

Nest the SUBSTITUTE Function to Substitute Multiple Characters

Step 2:

  • Press Enter.

Nest the SUBSTITUTE Function to Substitute Multiple Characters

Step 3:

  • Paste the formula in the other cells.

Nest the SUBSTITUTE Function to Substitute Multiple Characters


Method 3 – Performing the SUBSTITUTE Function Using the INDEX Function to Substitute Multiple Characters

The INDEX function is used to replace pairs from another table. Here, we will substitute red and blue with green and white.

Perform the SUBSTITUTE Function with INDEX Function to Substitute Multiple Characters

Step 1:

  • Enter the following formula in cell C5:
=SUBSTITUTE(SUBSTITUTE(B5,INDEX(E5:E6,=SUBSTITUTE(SUBSTITUTE(B5,INDEX(E5:E6,1),INDEX(F5:F6,1)),INDEX(E5:E6,2),INDEX(F5:F6,2))
  • INDEX find range is E5:E6

Perform the SUBSTITUTE Function with INDEX Function to Substitute Multiple Characters

Step 2:

  • Press Enter.

Perform the SUBSTITUTE Function with INDEX Function to Substitute Multiple Characters

  • Copy the formula in other cells.

Perform the SUBSTITUTE Function with INDEX Function to Substitute Multiple Characters


Method 4 – Applying the REPLACE Function to Substitute Multiple Characters

Below, we will substitute ‘Face’ for ‘Fact’ using the Replace Function.

Apply the REPLACE Function to Substitute Multiple CharactersApply the REPLACE Function to Substitute Multiple Characters

Step 1:

  • Enter the following formula in cell D5:
=REPLACE(B5, 4, 1,"t")

Apply the REPLACE Function to Substitute Multiple Characters

Step 2:

  • Press Enter.

Apply the REPLACE Function to Substitute Multiple Characters

Step 3:

  • Copy the formulas for the required cells.

Apply the REPLACE Function to Substitute Multiple Characters


Method 5 – Nesting the REPLACE Function to Substitute Multiple Characters

Below, we have a list of phone numbers in column A that are formatted: 123-456-789. We want to change them to: 123 456 789. To do that, we use the Replace Function.

Nest REPLACE Function

Step 1:

  • Enter the following formula in cell C5:
=REPLACE(REPLACE(B5,4,1," "),8,1," ")

Nest REPLACE Function

Step 2:

  • Press Enter.

Nest REPLACE Function

Step 3:

  • Copy the formula and repeat the steps for the required cells.

Nest REPLACE Function


Method 6 – Combining Multiple Functions to Substitute Multiple Characters

Below, the Reduce Function shows the value in the cell range C5:C7. If the criteria match, it substitutes the value in column B and adjusts column C.

Step 1:

  • Enter the following formula in cell D5:
=REDUCE(B5,$C$5:$C$7,LAMBDA(a,b,SUBSTITUTE(a,b,OFFSET(b,0,1))))

Combining multiple functions

Step 2:

  • Copy the formula to cell D7.

Final output


Method 7 – Run VBA Code to Substitute Multiple Characters

Below, we will run a VBA code to substitute multiple characters. We have used the same phone number example as Method 5.

Run A VBA Code

To run a VBA code to substitute multiple characters, just follow the steps described below.

Step 1:

  • Press Alt + F11 to open the Macro-Enabled Worksheet.
  • Go to the Insert tab.
  • Select Module.

Run A VBA Code

Step 2:

  • Past the following VBA code into the program window:
Sub replaceAll()

'declare object variable to hold reference to cell you work with
Dim myCell As Range

'declare variables to hold parameters for string replacement (string to replace and replacement string)
Dim myStringToReplace As String
Dim myReplacementString As String

'identify cell you work with
Set myCell = ThisWorkbook.Worksheets("VBA").Range("C5")
'specify parameters for string replacement (string to replace and replacement string)
myStringToReplace = "234-235-5689"
myReplacementString = "234 235 5689"

'replace all occurrences within string in cell you work with, and assign resulting string to Range.
'Value property of cell you work with
myCell.Value = Replace(Expression:=myCell.Value, 
Find:=myStringToReplace, Replace:=myReplacementString)

End Sub
  • Press Enter.

Run A VBA Code


Download Practice Workbook

Download this practice workbook to the exercises.

If you have any questions – Feel free to ask us. Also, feel free to leave comments in the section below.

Stay with us & keep learning.


Related Articles


<< Go Back to Find and Replace | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Bhubon Costa
Bhubon Costa

Bhubon Costa, B.Sc. in Naval Architecture & Marine Engineering from Bangladesh University of Engineering & Technology, has worked with the ExcelDemy since 2021. Currently, he has been working as a reviewer. Notably, he has written over 90 articles and led several VBA content development teams. He has a great passion for the fields of data analytics and data science. His areas of expertise include Excel VBA, Power Query, Pivot Table, Power BI, MySQL, PostgreSQL, machine learning, and Python... Read Full Bio

2 Comments
  1. No need to use VBA anymore for this! Super simple formula now!

    =REDUCE(A1,$b$2:$b$6,LAMBDA(a,b,SUBSTITUTE(a,b,OFFSET(b,0,1))))

    Where A1 is the target cell to replace text
    b2:b6 is where the keywords are stored (texts to be replaced)
    c2:c6 (referenced by the offset) is where the replacing texts are stored

    Credit: Chandoo

    • Hello JACOB FLOYD,
      Thanks for your valuable contribution. Now this method is added to this article. Please let us know if you have any queries regarding this article.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo