How to Use TEXTSPLIT, TEXTBEFORE, and TEXTAFTER in Excel

For decades, splitting text with formulas meant combining LEFT, RIGHT, MID, FIND, and LEN into fragile expressions that were painful to debug. Excel’s modern text functions (TEXTBEFORE, TEXTAFTER, and TEXTSPLIT) replace those workarounds with clean, readable formulas that update automatically.

Unlike the static Text to Columns wizard, these functions are fully dynamic and recalculate whenever the source text changes. They are available in Microsoft 365, Excel 2024, and Excel for the Web.

Quick Overview of the Three Functions

Function What It Does Basic Syntax
TEXTBEFORE Extracts text before a specific delimiter. =TEXTBEFORE(text, delimiter, [instance_num])
TEXTAFTER Extracts text after a specific delimiter. =TEXTAFTER(text, delimiter, [instance_num])
TEXTSPLIT Splits text across multiple columns and/or rows. =TEXTSPLIT(text, col_delimiter, [row_delimiter])

Step-by-Step: Extract Parts of an Email with TEXTBEFORE and TEXTAFTER

Suppose cells A2:A4 contain email addresses: anna.smith@northwind.com, mark.lee@contoso.org, and sara.chen@fabrikam.net.

  1. Step 1: Extract the Username Using TEXTBEFORE

    Click cell B2 and enter the formula below to capture everything before the @ symbol:

    =TEXTBEFORE(A2, "@")

    Press Enter. Excel returns anna.smith. Drag the formula down to B4.

  2. Step 2: Extract the Domain Using TEXTAFTER

    Click cell C2 and enter the formula below to capture everything after the @ symbol:

    =TEXTAFTER(A2, "@")

    Press Enter. Excel returns northwind.com. Drag down to C4.

  3. Step 3: Search from the End Using a Negative Instance Number

    What if you have a file path like C:\Reports\2026\Q1\Sales.xlsx in cell A6 and only want the file name after the last backslash? Set the third argument (instance_num) to -1 to count backward from the end:

    =TEXTAFTER(A6, "\", -1)

    Press Enter. Excel immediately returns Sales.xlsx.

Step-by-Step: Split a Cell into Multiple Columns Using TEXTSPLIT

Suppose cell A9 contains a full address string: 742 Evergreen Terrace, Springfield, IL, 62704.

  1. Click cell B9 and make sure cells C9:E9 to the right are empty so the formula can spill.
  2. Enter the TEXTSPLIT formula using ", " (a comma followed by a space) as the column delimiter:
    =TEXTSPLIT(A9, ", ")
  3. Press Enter. Excel automatically splits the text across four separate columns:
    • B9: 742 Evergreen Terrace
    • C9: Springfield
    • D9: IL
    • E9: 62704

Step-by-Step: Split Text into a 2D Table (Both Columns and Rows)

TEXTSPLIT can break a single cell into rows and columns simultaneously. Suppose cell A12 holds packed key-value data: Laptop:1200;Monitor:400;Keyboard:85.

  1. Click cell B12 with empty space below and to the right.
  2. Pass ":" as the col_delimiter and ";" as the row_delimiter:
    =TEXTSPLIT(A12, ":", ";")
  3. Press Enter. Excel spills a clean 3-row by 2-column table:
Column B Column C
Laptop 1200
Monitor 400
Keyboard 85

Handling Extra Delimiters and Missing Matches

  • Ignore empty cells from repeated delimiters: If your text contains double commas like Apple,,Banana, set the fourth argument (ignore_empty) to TRUE:
    =TEXTSPLIT(A2, ",", , TRUE)
  • Prevent #N/A errors when a delimiter is missing: In TEXTBEFORE and TEXTAFTER, you can provide a custom fallback in the sixth argument (if_not_found):
    =TEXTBEFORE(A2, "@", 1, 0, 0, "Invalid Email")
  • Case-insensitive matching: By default, all three functions are case-sensitive. Set the match_mode argument to 1 to ignore uppercase and lowercase differences.

When to Use Older Text Formulas Instead

If you share workbooks with colleagues running Excel 2019 or earlier, these three functions will return a #NAME? error. For backward compatibility, use our classic walkthrough on how to cut pieces of text in Excel.

See also  Why Does VLOOKUP Give Me the Wrong Value?