To extract text before a character in Excel, use TEXTBEFORE in Microsoft 365 or Excel 2024; older versions can use LEFT with FIND.
The right choice depends on your Excel version and what should happen when the character is missing or appears more than once.
Use TEXTBEFORE to extract text before a character
If cell A2 contains North-Region, this formula returns the text before the hyphen:
=TEXTBEFORE(A2,"-")
The result is North.
TEXTBEFORE searches for the delimiter you specify and returns the characters to its left.
It works with a single character, such as a comma, or a longer text string, such as - .
For example, if A2 contains Lee, Morgan, use:
=TEXTBEFORE(A2,",")
The result is Lee.
The comma is excluded from the result.
Extract text before a space, slash, or other delimiter
Replace the delimiter in the formula with the character or text that separates the part you want from the rest.
Suppose A2 contains INV 2048, and you want the invoice prefix:
=TEXTBEFORE(A2," ")
This returns INV.
To extract the folder name from reports/2026/sales.xlsx, use a slash as the delimiter:
=TEXTBEFORE(A2,"/")
This returns reports.
If the delimiter includes spaces on both sides, match them exactly.
For Product - Blue, use " - " to return Product without leaving a trailing space.
Return text before the last occurrence
By default, TEXTBEFORE uses the first match.
If A2 contains west-east-north, then =TEXTBEFORE(A2,"-") returns west.
To return everything before the last hyphen instead, set the instance number to -1:
=TEXTBEFORE(A2,"-",-1)
The result is west-east.
The instance number can also target another occurrence: 2 selects the second match, while -2 selects the second-to-last match.
Use TEXTBEFORE with an older Excel formula
TEXTBEFORE is available in Microsoft 365 and Excel 2024, but it is not supported in every older Excel release.
For those versions, combine LEFT and FIND.
If A2 contains North-Region, use:
=LEFT(A2,FIND("-",A2)-1)
FIND returns the character position of the hyphen.
Subtracting 1 excludes it, and LEFT returns that many characters from the start of the text.
The formula returns North.
FIND is case-sensitive.
If the delimiter is a letter and matching should ignore case, use SEARCH instead:
=LEFT(A2,SEARCH("x",A2)-1)
For a case-sensitive match with an older Excel version, keep FIND.
Both functions return an error if they cannot find the delimiter.
Handle cells that do not contain the delimiter
TEXTBEFORE returns a #N/A error when the delimiter is missing unless you provide a value for its optional if_not_found argument.
To return the original cell contents when there is no hyphen, use:
=TEXTBEFORE(A2,"-",1,0,0,A2)
The arguments set the match to the first occurrence, use case-sensitive matching, and specify A2 as the fallback.
If A2 contains North-Region, the result is North; if it contains North, the result stays North.
A shorter alternative is to catch the error with IFERROR:
=IFERROR(TEXTBEFORE(A2,"-"),A2)
For the older LEFT and FIND method, wrap the formula similarly:
=IFERROR(LEFT(A2,FIND("-",A2)-1),A2)
These formulas return the original cell value if there is no match.
If you would rather return a blank, replace the final A2 with "".
Extract text before a delimiter in every row
Enter the formula in B2 next to the first source value, then fill it down for the rest of the rows.
For example, with values in A2:A4, enter:
=TEXTBEFORE(A2,"-")
Copy or drag the formula from B2 through B4.
The relative reference updates automatically: B3 refers to A3, and B4 refers to A4.
If your data is formatted as an Excel Table, a formula in the new column can fill down automatically.
To use a delimiter stored in another cell, such as D1, refer to that cell in the formula:
=TEXTBEFORE(A2,$D$1)
The dollar signs keep the delimiter reference fixed when you fill the formula down.
This is useful when you need to change the delimiter without editing each formula.
Check these delimiter and compatibility edge cases
- Delimiter at the start: If the value begins with the delimiter, the result is an empty string because there are no characters before it.
- Delimiter at the end: The formula returns all characters before that final delimiter.
A trailing space may remain if the delimiter is not an exact match. - Delimiter appears more than once: TEXTBEFORE uses the first occurrence by default.
Set the instance number to -1 to use the last one. - Case sensitivity: TEXTBEFORE uses its
match_modeargument;0means case-sensitive and1means case-insensitive.
FIND is case-sensitive, while SEARCH is not. - Formula separators: Some regional settings use semicolons instead of commas between arguments.
If Excel rejects a comma-separated formula, replace the argument separators with semicolons. - Compatibility: If Excel reports that TEXTBEFORE is an unknown function, use the LEFT and FIND formula or update to a version that supports TEXTBEFORE.