How to Split Text in Excel into Multiple Rows: 6 Methods

Method 1 – Splitting Text into Multiple Rows Using FILTERXML and SUBSTITUTE Functions 

Steps:

  • Rearrange our data in a simpler way.

  • Type the following formula in cell B7.
=FILTERXML("<s>" &SUBSTITUTE(B5,";", "</s><s>") & "</s>", "//s")

how to split text in excel into multiple rows

The formula here splits the texts in cell B5 into the 7th to 9th rows based on Semicolon (;).

  • Press ENTER and you will see the text in cell B5 split into different rows.

  • Drag the Fill Handle icon to the right to AutoFill the following cells.

how to split text in excel into multiple rows

You can easily split your text into multiple rows.


Method 2 – Using Text to Columns Feature and TRANSPOSE Function to Split Text into Multiple Rows

Steps: 

  • Select the range of cells that contain the texts that you want to split. The range is C4:C8.

  • Go to Data >> Text to Columns.
  • The Text to Columns wizard will appear. Split our texts by delimiter, check this in the wizard.
  • Click Next.

how to split text in excel into multiple rows

  • Our preferred delimiter is a Semicolon(;), so check Semicolon and click Next.

  • You will see a preview of how your data will look after this operation. Click Finish.

how to split text in excel into multiple rows

  • Then you will see the split data in your Excel sheet.

  • Our goal was to split these texts into multiple rows, so we will use a formula that will do it. Type the following formula in cell B10.
=TRANSPOSE(C4:E8)

how to split text in excel into multiple rows

The TRANSPOSE function converts the columns to rows and rows to columns. By doing that, it splits our desired texts into 10th to 11th rows.

  • Hit ENTER, and you will see all the texts split into multiple rows.

You can split text into multiple rows by using the Text to Columns Feature and TRANSPOSE function.


Method 3 – Applying Power Query Editor to Split Text into Multiple Rows

Steps:

  • Select the cells B4:C8 and go to Data >> From Table/Range
  • A dialog box will appear. Click OK. Make sure that you check My table has headers.

how to split text in excel into multiple rows

You will see your data in a Power Query Editor.

  • Select the Product; Brand; Price column from the Power Query Editor.
  • Go to Home >> Split Column >> By Delimiter

how to split text in excel into multiple rows

  • The Split Column by Delimiter window will open after that. As our texts have semicolons, we chose Semicolon as our delimiter.
  • Split each text, so we select Each occurrence of the delimiter in the Split at section
  • Split texts into rows, and we select Advanced options >> Rows.
  • Click OK.

You will see all the texts split into multiple rows.

how to split text in excel into multiple rows

  • If you want to load this table in an Excel sheet, click Close & Load.

This operation will transfer these data into a new Excel sheet.

how to split text in excel into multiple rows

Thus you can split a text into multiple rows with the help of the Power Query Editor.


Method 4 – Creating a Function Using VBA to Split Text into Multiple Rows in Excel

Steps:

  • Open Visual Basic from the Developer Tab.

  • You will see the VBA window appear. Go to Insert >> Module.

how to split text in excel into multiple rows

  • Now type the following code in the VBA Module.
Function TextSplit(Text As String, Delimiter As String) As String()
On Error Resume Next
TextSplit = Split(Text, Delimiter)
On Error GoTo 0
End Function

Define our Function TextSplit as String. This will take both Text and Delimiter as strings. The VBA Split Function will split the texts based on Delimiters.

  • Go back to your sheet and type the following formula in cell B7
=TRANSPOSE(TextSplit(B5,";"))

how to split text in excel into multiple rows

The TextSplit function will split the texts into columns first and then it will split into rows with the help of the TRANSPOSE function.

  • Hit ENTER, and you will see the text in cell B5 splits into 3 different rows.

  • Drag the Fill Handle icon to the right to AutoFill the following cells.

how to split text in excel into multiple rows

You can split your text into multiple rows using a user-defined function by VBA and TRANSPOSE Function.


Method 5 – Using ROW & VBA Custom Functions to Split Text into Multiple Rows

Steps:

  • Follow Section 4 to open the VBA Module.
  • Type the following code in the VBA Module.
Function TextSplitManual(Text As String, Delimiter As String, _
Product As Integer) As String
On Error Resume Next
TextSplitManual = Split(Text, Delimiter)(Product - 1)
On Error GoTo 0
End Function

We define our Function TextSplitManual as String. This will take both Text and Delimiter as strings. We added a new variable Product as Integer which will return the splitted parts of the text one by one. The VBA Split Function will split the texts based on Delimiters.

  • Go back to your sheet and type the following formula in cell B7
=TextSplitManual(B$5,";",ROWS($B$5:B5))

how to split text in excel into multiple rows

  • Hit the ENTER button to see the first text in cell B5 which is the product name Laptop.

  • Drag the Fill Handle icon downward to AutoFill the cell. This will show you the 2nd text of cell B5.

how to split text in excel into multiple rows

  • Drag the Fill Handle icon again to the right to AutoFill the following cells.

See the first 2 texts manually. If you have a change of mind and want to see the prices, drag the Fill Handle icon downward.

how to split text in excel into multiple rows

Thus you can easily split your text into multiple rows manually using a user-defined function by VBA and ROWS Function.


Method 6 – Using a VBA Code to Split Text into Multiple Rows Instantly

Steps:

  • Follow Section 4 to open the VBA Module.
  • Type the following code in the VBA Module.
Option Explicit
Sub SplitToRows()
  Dim k As Long
  Dim Product_Info() As String
  Dim Set_Row As Long
  With Worksheets("vba")
    Set_Row = 5
    Do While True
      If .Cells(Set_Row, "C").Value = "" Then
        Exit Do
      End If
       Product_Info = Split(.Cells(Set_Row, "C").Value, ";")
      If UBound(Product_Info) > 0 Then
        .Cells(Set_Row, "C").Value = Product_Info(0)
        For k = 1 To UBound(Product_Info)
          Set_Row = Set_Row + 1
          .Rows(Set_Row).EntireRow.Insert
          .Cells(Set_Row, "C").Value = Product_Info(k)
          .Cells(Set_Row, "D").Value = .Cells(Set_Row - 1, "D").Value
        Next
      End If
      Set_Row = Set_Row + 1
    Loop
  End With
 End Sub

Code Explanation

  • We named our Sub Procedure as SplitInToRows.
  • We declared our variable types.
  • As the information on the Products begins from the 5th row, we set Set_Row to 5.
  • A VBA If Statement is provided within the Do While loop to check whether the cell is empty.
  • Used the VBA Split to split the texts and kept it in the Product_Info
  • The IF condition is as follows: when Product_Info is greater than 0 it will place the splitted values in the consecutive rows. Used a For Loop to go through the selection.

  • Go back to your sheet and Run the Macro named SplitInToRows as it is your current Macro.

how to split text in excel into multiple rows

  • After executing the command, the information of the products will be split into the lower cells.

how to split text in excel into multiple rows

Easily split text into multiple rows by using the VBA Do While Loop.


Download Practice Workbook


Related Articles


<< Go Back to Splitting TextSplit in ExcelLearn 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