Excel Extract Text Between Delimiters
By Szabó Gergő · Updated
Use TEXTBEFORE and TEXTAFTER on Microsoft 365, or MID and FIND on older Excel, to take the middle token of a code.
Syntax and arguments
=TEXTBEFORE(TEXTAFTER(A2,"-"),"-")- text
- The cell that contains delimiters, such as A2.
- delimiter
- The mark to split on, often - or /.
Text between delimiters examples
A2 is EAST-Q3-2026.
=TEXTBEFORE(TEXTAFTER(A2,"-"),"-")TEXTAFTER drops EAST-, TEXTBEFORE keeps Q3.
Same code in A2.
=MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1)The nested FIND locates the second hyphen so MID can take Q3.
A path in A2.
=TEXTAFTER(A2,"/",-1)Instance -1 reads from the right and returns the file name.
Common mistakes
Assuming every row has two hyphens
Wrap in IFERROR when the delimiter can be missing.
Using LEFT when you need the middle
LEFT only reads from the start. Use TEXTAFTER or MID.
Forgetting extra spaces
TRIM the result if the source has spaces around the delimiter.
Text between delimiters FAQ
Does TEXTSPLIT exist?
Yes in Microsoft 365. =INDEX(TEXTSPLIT(A2,"-"),2) also returns the middle token.
Can I split to columns?
Data > Text to Columns is fine for a one-time split. Use formulas when the source keeps changing.
What about Google Sheets?
REGEXEXTRACT or SPLIT is usually simpler than nested FIND.