Split text with delimiter in a cell in Excel
Actually, the build-in Text to Columns function in Excel can help you quickly split text with certain delimiter. Another option, you can apply formula to achieve it. In this article, we are providing a step-by-step guide to help you split text with delimiter by applying a combination of the TRIM, MID, SUBSTITUTE, REPT and the LEN functions in Excel.
How to split text in a cell with certain delimiter in Excel?
Firstly, prepare your data. Supposing you have prepared a text string list in column B as the below screenshot shown, beyond that, you need to create three helper columns containing number 1, 2 and 3 separately in the column cells.
Generic formula
=TRIM(MID(SUBSTITUTE(A1, delimiter,REPT(" ",LEN(A1))),(N-1)*LEN(A1)+1,LEN(A1)))
Arguments
A1: Represents the cell which contains the text string you want to split with delimiter;
Delimiter: The delimiter you want to split text based on;
The delimiter needs to be enclosed in quotation marks.
N: Here this letter N refers to the number in the helper columns.
How to use this formula?
1. Select a blank cell to output the first text you will split. In this case, I select cell C3.
2. Enter the below formula into it and press the Enter key.
=TRIM(MID(SUBSTITUTE($B3,"-",REPT(" ",LEN($B3))),(G$3-1)*LEN($B3)+1,LEN($B3)))
3. Select the result cell, drag the Fill Handle right to the adjacent two cells to extract the second and third texts.
4. Keep the above three cells selected, and then drag the Fill Handle down to split other text strings in the same table with the same delimiter. See screenshot:
Now each text string in specific cells have been split into separate column cells by delimiter "-".
How this formula works?
=TRIM(MID(SUBSTITUTE($B3,"-",REPT(" ",LEN($B3))),(G$3-1)*LEN($B3)+1,LEN($B3)))
1. SUBSTITUTE($B3,"-",REPT(" ",LEN($B3)))
- REPT(" ",LEN($B3)): The LEN function returns the total number of characters in KTE-Jan-359 (here the result is 11). And then the REPT function repeats a space 11 times. The result is " " (there are 11 spaces enclosed in quotation marks);
- SUBSTITUTE($B3,"-", " "): The SUBSTITUTE function replaces each dash "-" in text string "KTE-Jan-359" with 11 spaces. And returns the result as "KTE Jan 359".
2. MID("KTE Jan 359",(G$3-1)*LEN($B3)+1,LEN($B3))
- MID("KTE Jan 359",1,11): The MID function returns 11 characters starting from the first character of "KTE Jan 359". The result is "KTE ".
Note: The letter N is refered to $B3, and the value in $B3 is number 1, here the starting point is calculated with (G$3-1)*LEN($B3)+1 = 1.
3. TRIM("KTE "): The TRIM function removes all extract spaces from "KTE " and finally returns the result as KTE.
Related functions
Excel TRIM function
The Excel TRIM function removes all extra spaces from text string and only keeps single spaces between words.
Excel MID function
The Excel MID function is used to find and return a specific number of characters from the middle of given text string.
Excel SUBSTITUTE function
The Excel SUBSTITUTE function replaces text or characters within a text string with another text or characters.
Excel LEN function
The Excel LEN function returns the number of characters in a text string.
Related formulas
Split dimensions into two parts in Excel
This article explains how to use formulas to split dimensions in a cell into two parts without units (individual length and width).
Separate numbers from units of measurement
This article explains how to use formula to separate numbers from unites of measurement.
Split text and numbers in a cell in Excel
If you want to split text and numbers in a cell into different column cells with formulas, this formula tutorial will do you a favor.
Split Text String At Specific Character In A Cell In Excel
This tutorial explains how to split texts string at a specific character into separate column cells with formulas in Excel.
The Best Office Productivity Tools
Kutools for Excel - Helps You To Stand Out From Crowd
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...
Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.