How to Use an Excel Formula to Replace Text with Number (5 Examples)

 

Method 1 – Applying an Excel Formula with the SUBSTITUTE Function to Replace Text with Number

Steps:

  • Select cell C4.
  • Enter the following formula:
=SUBSTITUTE(B4," to"," 2")
  • Press Enter. It’ll return the desired result.

Excel Formula with SUBSTITUTE Function to Replace Text with Number

NOTE: The SUBSTITUTE function looks for ‘to’ (old text) in cell B4 and replaces it with ‘2’ (new text).
  • Use AutoFill to complete the changes in the following cells.


Method 2 – Inserting the Nested SUBSTITUTE Formula for Replacing Text

Steps:

  • Select cell C4.
  • Enter the following formula:
=SUBSTITUTE(SUBSTITUTE(B4,"One","1"),"to","2")
  • Press Enter and use AutoFill to fill the series.

How Does the Formula Work?

  • SUBSTITUTE(B4,”One”,”1″)

The SUBSTITUTE function replaces ‘One’ with ‘1’ in cell B4.

  • SUBSTITUTE(SUBSTITUTE(B4,”One”,”1″),”to”,”2″)

Finally, this SUBSTITUTE formula replaces ‘to’ with ‘2’ in the output of SUBSTITUTE(B4,”One”,”1″).

Read More: How to Replace Text in Selected Cells in Excel


Method 3 – Applying the Excel REPLACE Function to Substitute Text with Number

Steps:

  • Select cell C4.
  • Enter the following formula:
=REPLACE(B4,6,2,"2")
  • Press Enter to make the changes.

Apply Excel REPLACE Function for Substituting Text with Number

NOTE: You can’t use AutoFill in this case, as the starting position is different for different cells.

Read More: How to Replace Text between Two Characters in Excel


Method 4 – Using an Excel Formula with REPLACE and FIND Functions

Steps:

  • Select cell C4.
  • Enter the following formula:
=REPLACE(B4, FIND("to",B4), 2, "2")
  • Press Enter and use AutoFill to get the required output.

Substitute Text Using Excel Formula with REPLACE and FIND Functions

How Does the Formula Work?

  • FIND(“to”,B4)

The FIND function seeks the starting position of ‘to’ in cell B4 and returns 6.

  • REPLACE(B4, FIND(“to”,B4), 2, “2”)

Lastly, the REPLACE formula substitutes ‘to’ with ‘2’.

Read More: How to Replace Text after Specific Character in Excel


Method 5 – Applying the Nested REPLACE Formula to Exchange Text with Number

Steps:

  • Select cell C4.
  • Enter the following formula:
=REPLACE(REPLACE(B4,10,2,"2"),1,3,"1")
  • Press Enter. It’ll return the changes.

Nested REPLACE Formula to Exchange Text with Number

NOTE: As the starting position doesn’t match in every cell, we can’t use AutoFill.

How Does the Formula Work?

  • REPLACE(B4,10,2,”2″)

The REPLACE function substitutes ‘to’ in cell B4 with ‘2’.

  • REPLACE(REPLACE(B4,10,2,”2″),1,3,”1″)

Lastly, this REPLACE formula substitutes ‘One’ with ‘1’ in the output of REPLACE(B4,10,2,”2″).


Replace Text with a Number without Using an Excel Formula

Steps:

  • Select cell B4.

Replace Text with Number without Using Excel Formula

  • Press the keys Ctrl and H together.
  • As a result, the ‘Find and Replace’ dialog box will pop out.
  • Type ‘to’ in the Find what box and type 2 in the Replace with box.
  • Press Replace All.

  • It’ll return the desired output as shown in the following picture.


Download the Practice Workbook

Download the following workbook to practice.


<< Go Back to Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Aung Shine
Aung Shine

Aung Shine completed his bachelor’s in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. It has been almost 2 years since he joined SOFTEKO and actively working on the ExcelDemy project. Currently he works as a Team Leader where he guides his team members to create technical content. He has published 150+ articles and reviewed 50+ articles. He has also solved various user problems before. He has interests in Data Analysis, Power Query, Advanced Excel,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo