Split Text by a Delimiter

Excel 365 has TEXTSPLIT and Google Sheets has SPLIT, each cutting text at a character you choose. Older versions of Excel need a longer formula, shown below along with how to take just the first, second, or last piece.

Free, no sign-up required · 5 free generations a day

Last updated

Describe your task, get the formula

Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.

Split text formulas

Syntax
=TEXTSPLIT(A2, ",")
=SPLIT(A2, ",")
=TRIM(MID(SUBSTITUTE(A2, ",", REPT(" ", 100)), (n-1)*100+1, 100))

TEXTSPLIT works in Microsoft 365 only and SPLIT in Google Sheets. The third formula returns piece number n in any version of Excel by padding each delimiter with 100 spaces, cutting out a 100-character slice, and trimming it.

Examples

Split into columns

=TEXTSPLIT(A2,",")

In Microsoft 365 the pieces spill into the cells to the right. In Google Sheets use =SPLIT(A2,",") for the same result.

Get the second item in any Excel version

=TRIM(MID(SUBSTITUTE(A2,",",REPT(" ",100)),101,100))

Replaces each comma with 100 spaces, takes the slice that starts at character 101 — the second piece — and trims the spaces. Change 101 to 201 for the third piece, 301 for the fourth.

Get the text after the last slash

=TRIM(RIGHT(SUBSTITUTE(A2,"/",REPT(" ",100)),100))

Pads every slash, takes the last 100 characters, and trims them, which leaves only the final piece such as a file name. In Microsoft 365, =TEXTAFTER(A2,"/",-1) does the same.

Common mistakes and how to fix them

#NAME? with TEXTSPLIT

TEXTSPLIT is only in Microsoft 365 and Excel for the web. In Excel 2021 and earlier, use Text to Columns on the Data tab or the SUBSTITUTE and MID formula.

#SPILL! error

TEXTSPLIT and SPLIT write into the cells to the right. If any of them already contain data, clear those cells.

SPLIT cuts at the wrong places in Google Sheets

By default SPLIT treats every character in the delimiter separately, so ", " splits at commas and at spaces. Add FALSE as the third argument: =SPLIT(A2,", ",FALSE).

Frequently asked questions

How do I get only one piece in Google Sheets?

Wrap SPLIT in INDEX: =INDEX(SPLIT(A2,","),1,2) returns the second piece.

Why are there leading spaces in the pieces?

A list like "red, green, blue" has a space after each comma. Split on "," and wrap the result in TRIM, or split on ", " including the space.

Can I split text without a formula?

Yes. In Excel use Data, Text to Columns. In Google Sheets use Data, Split text to columns. These make a one-off change instead of a live formula.

Don't want to write it by hand?

Describe what you need in plain English and get a ready-to-use formula in seconds.

Try the formula generator