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.
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.
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?
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.