How to Add Text in the Middle of a Cell in Excel – 5 Easy Methods

The dataset showcases IDs of different Smartphone Products.

how to add text in the middle of a cell in excel


Method 1 – Using the Excel LEFT and MID Functions to Add Text in the Middle of a Cell

You want to insert M after every second number in Product IDs.

Steps:

  • Create a new column for the new IDs and enter the following formula in D5.

=LEFT(C5,2) & "M" & MID(C5,3,6)

The formula divides the text in C5 into two parts. The LEFT function returns the first two characters of the ID of C5 and the MID function returns 6 characters starting from the 3rd character of the ID. The Ampersand adds M between these two parts.

  • Press ENTER to see the output.

how to add text in the middle of a cell in excel using LEFT and MID functions

Read More: How to Add Text to End of Cell in Excel


Method 2 – Applying the REPLACE Function to Add Text in the Middle of a Cell

Steps:

  • Create a new column for the new IDs and enter the following formula in D5.

=REPLACE(C5,3,0,"M")

how to add text in the middle of a cell in excel

The formula will add  M after the 2nd character of the text in C5.

  • Press ENTER.
  • Drag the Fill Handle to AutoFill the rest of the cells.

 


Method 3 – Combining Functions to Add Text in the Middle of a Cell

Steps:

  • Create a new column for the new IDs and enter the following formula in D5.

=CONCATENATE(LEFT(C5,2),"M",RIGHT(C5,LEN(C5)-2))

how to add text in the middle of a cell in excel

The formula will add M after the 2nd character of the text in C5.

Formula Breakdown

  • LEN(C5)-2—-> returns the subtraction result between the character length of C5 and 2.
    • Output: 6
  • RIGHT(C5,LEN(C5)-2)—-> becomes
  • RIGHT(C5,6)—-> turns into
    • Output: “ABD344”
  • LEFT(C5,2)—-> returns the two first characters of the text in C5.
    • Output: “23”
  • CONCATENATE(LEFT(C5,2),”M”,RIGHT(C5,LEN(C5)-2))—-> becomes
  • CONCATENATE( “23”,”M”, “ABD344”)—-> results into
    • Output: “23MABD344”
  • Press ENTER.
  • Drag the Fill Handle to AutoFill the rest of the cells.

Read More: How to Add Text in Excel Spreadsheet


Method 4 – Adding Text in the Middle of a Cell Using VBA

Steps:

  • Go to the Developer Tab and select Visual Basic.

how to add text in the middle of a cell in excel using VBA

  • In the VBA editor, select Insert >> Module to open a VBA Module.

  • Enter the following code in the VBA Module.
Sub AddTextInCell()
Dim mnCell As Range, nSelected_Range As Range
Set nSelected_Range = Application.Selection
Set nSelected_Range = Application.InputBox _
("Select the Range", _
"Add Text", nSelected_Range.Address, Type:=8)
For Each mnCell In nSelected_Range
mnCell.Value = VBA.Left(mnCell.Value, 2) & "M" & _
VBA.Mid(mnCell.Value, 3, VBA.Len(mnCell.Value) - 1)
Next
End Sub

how to add text in the middle of a cell in excel

This VBA code will add M in the Product IDs like in Method 1 and 2.

The VBA Left, Mid and Len functions were used. Also, a For Loop. The coding is similar to the formula used in Method 1.

  • Go back to your sheet and run the Macro: AddTextInCell.

  • In the message box, select the range of IDs you want to update and click OK.

how to add text in the middle of a cell in excel

You will see the Product IDs with an M after the 2nd character.

Read More: How to Add Text to Cell Value in Excel


Method 5 – Applying the SUBSTITUTE Function to Add Text Based on Criteria

Steps:

To add an X after every A in the Product IDs:

  • Create a new column for the new IDs and enter the following formula in D5.

=SUBSTITUTE(C5,"A","AX")

how to add text in the middle of a cell in excel using SUBSTITUTE function

The formula will add an X whenever it finds an A.

  • Press ENTER.
  • Drag the Fill Handle to AutoFill the rest of the cells.

Read More: How to Add Text to Beginning of Cell in Excel


Practice Section

Practice here.

how to add text in the middle of a cell in excel


Download Practice Workbook


Related Articles


<< Go Back to Excel Add Text to Cell Value | Concatenate Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Meraz Al Nahian
Meraz Al Nahian

Md. Meraz Al Nahian has worked with the ExcelDemy project for over 1.5 years. He wrote 140+ articles for ExcelDemy. He also solved a lot of user problems and worked on dashboards. He is interested in data analysis, advanced Excel, statistics, and dashboards. He also likes to explore various Excel and VBA applications. He completed his graduation in Electrical & Electronic Engineering from Bangladesh University of Engineering & Technology (BUET). He enjoys exploring Excel-related features to gain efficiency... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo