In this guide, we’re going to show you how to split text in Excel by a delimiter.

Download Workbook

We have a sample data which contains concatenated values separated by “|” characters. It is important that the data includes a specific delimiter character between each chunk of data to make splitting text easier.

Text to Columns feature for splitting text

When splitting text in Excel, the Text to Columns is one of the most common methods. You can use the Text to Columns feature with all versions of Excel. This feature can split text by a specific character count or delimiter.

  1. Start with selecting your data. You can use more than one cell in a column.
  2. Click Data > Text to Columns in the Ribbon.
  3. On the first step of the wizard, you have 2 options to choose from – these are slicing methods. Since our data in this example is split by delimiters, our choice is going to be Delimited.
  4. Click Next to continue
  5. Select the delimiters suitable to your data or choose a character length and click Next.
  6. Choose corresponding data types for the columns and the destination cell. Please note that if the destination cell is the same cell as where your data is, the original data will be overwritten.
  7. Click Finish to see the outcome.

How to split text by delimiter in Excel 02

Check out How to use Text to Columns in Excel to learn more about this method.

Using formulas to split text

Excel has a variety of text formulas that you can use to locate delimiters and parse data. When using formulas to do so, Excel automatically updates the parsed values when the source is updated.

The formula used in this example uses Microsoft 365’s dynamic array feature, which allows you to populate multiple cells without using array formulas. If you can see the SEQUENCE formula, you can use this method.

Syntax

=TRIM(MID(SUBSTITUTE( text, separator, REPT( “ “, LEN( text ))),(SEQUENCE( 1, column count ) – 1 ) * LEN( text ) + 1,LEN( text )))

How it works

The formula replaces each separator character with space characters first. (see SUBSTITUTE) The number of space characters will be equal to the original string’s character count, which is enough number of spaces to separate each string block (see REPT and LEN).

The SEQUENCE function generates an array of numbers starting with 1, up to the number of maximum columns. Multiplying these sequential numbers with the length of the original string returns character numbers indicating the start of each block.

This approach uses the MID function to parse each string block with given start character number and the number of characters to return. Since the separators are replaced with space characters, each parsed block includes these spaces around the actual string. The TRIM function then removes these spaces.

How to split text by delimiter in Excel 03

You can get detailed information about formulas for splitting a text in How to split text with formulas in Excel article.

Flash Fill

The Flash Fill is an Excel tool which can detect the pattern when entering data. A common example is to separate or merge first name and last names. Let’s say column A contains the first name – last name combinations. If you type in the corresponding first name in the same row for column B, Excel shows you a preview for the rest of the column.

Please note that the Flash Fill is available for Excel 2013 and newer versions only.

You can see the same behavior with strings using delimiters to separate data. Just select a cell in the adjacent column and start typing. Occasionally Excel will display a preview. If not, press Ctrl + E like below to split your text.

You can check Create Tables and Manipulate Data in an Instant with Excel Flash Fill  article to learn more about Flash Fill.

Power Query

Power Query is a powerful feature, not only for splitting text, but for data management in general. Power Query comes with its own text splitting tool which allows you to split text in multiple ways, like by delimiters, number of characters, or case of letters.

If you are using Excel 2016 or newer – including Microsoft 365 – you can find Power Query options under the Data tab’s Get & Transform section. Excel 2010 and 2013 users should download and install the Power Query as an add-in.

  1. Select the cells containing the text.
  2. Click Data > From Sheet. If the data is not in an Excel Table, Excel converts it into an Excel Table first.
  3. Once the Power Query window is open, find the Split Column under the Transform tab and click to see the options.
  4. Select the approach that fits your data layout. The data in our example is using By Delimiter since the data is separated by “|”.
  5. Power Query will show the delimiter character. If you are not seeing the expected delimiter, choose from the list or enter it yourself.
  6. Click OK to split text.
  7. If your data includes headers in its first row, like our example does, click Transform > Use First Row as Headers to keep them as headers.
  8. One you satisfied with the result, click the Home > Close & Load button to move the split data into your workbook.

A detailed information about splitting text with Power Query is in How to split text with Power Query in Excel.

VBA

VBA is the last text splitting option we want to show in this article. You can use VBA in two ways to split text:

  1. By calling the Text to Columns feature using VBA,
  2. Using VBA’s Split function to create array of sub-strings and using a loop to distribute the sub-strings into adjacent cells in the same row.

Text to Columns by VBA

The following code can split data from selected cells into the adjacent columns. Note that each supported delimiter is listed as an argument which you can enable or disable by giving them either True or False. Briefly, True means that you want to set that argument as a delimiter and False means ignore that character.

An easy way to generate a VBA code to split text is to record a macro. Start a recording section using the Record Macro button in the Developer tab, and use the Text to Columns feature. Once the recording is stopped, Excel will save the code for what you did during recording.

The code:

Sub VBATextToColumns_Multiple()
Dim MyRange As Range
Set MyRange = Selection ‘To work on a static range replace Selection via Range object, e.g., Range(“B6:B12”)

MyRange.TextToColumns _
Destination:=MyRange(1, 1).Offset(, 1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
SemiColon:=False, _
Comma:=False, _
Space:=False, _
Other:=True, _
OtherChar:=”|”
End Sub

Split Function

Split function can be useful if you want to keep the split blocks in an array. You can only use this method for splitting because of the single delimiter constraint. The following code loops through each cell in a selected column, splits and stores text by the delimiter “|”, and uses another loop to populate the values in the array on cells. The final EntireColumn.AutoFit command adjusts the column widths.

The code:

Sub SplitText()
Dim StringArray() As String, Cell As Range, i As Integer
For Each Cell In Selection ‘To work on a static range replace Selection via Range object, e.g., Range(“B6:B12”)
StringArray = Split(Cell, “|”) ‘Change the delimiter with a character suits your data
For i = 0 To UBound(StringArray)
Cell.Offset(, i + 1) = StringArray(i)
Cell.Offset(, i + 1).EntireColumn.AutoFit ‘This is for column width and optional.
Next i
Next
End Sub

Detailed information can be found in How to split text with VBA in Excel.