Text formula page
Extract Text Before Character Formula
Use this when imported cells contain a prefix before a known separator.
Best for
Extract text before a character in Excel or Google Sheets.
What it returns
If A2 is SKU-1001-East, the result is SKU.
Copy formulas
=TEXTBEFORE(A2, "-")=INDEX(SPLIT(A2, "-"), 1, 1)Excel uses TEXTBEFORE for the text before the first delimiter, while Google Sheets uses SPLIT with INDEX to return the first segment.
Example data
| Raw Text | Example Result |
|---|---|
| Maya Chen | Maya |
| SKU-1001-East | SKU |
| https://www.example.com/pricing | example.com |
| Acme North | Acme North |
What it returns
If A2 is SKU-1001-East, the result is SKU.
How the formula works
- A2 is the source text.
- The dash is the delimiter.
- The result is the text before the first delimiter.
| Syntax piece | Role in the formula |
|---|---|
| A2 | The source text, such as SKU-1001-East. |
| "-" | The delimiter that marks where the returned prefix ends. |
| First segment | The shown formulas return the text before the first matching delimiter. |
Verified examples
=TEXTBEFORE(A2, "-")Excel: Enter SKU-1001-East in A2. Returns: SKU
=INDEX(SPLIT(A2, "-"), 1, 1)Google Sheets: Enter SKU-1001-East in A2. Returns: SKU
=TEXTBEFORE(A2, "|")Excel: Enter ABC|West in A2. Returns: ABC
Common errors and fixes
| Issue | Likely cause | Fix |
|---|---|---|
| The formula returns an error for a row without the delimiter | TEXTBEFORE or SPLIT cannot find the requested separator in that source text. | Check the delimiter or wrap the formula in IFERROR when missing separators are valid input. |
| The prefix contains an unexpected space | The source has spaces immediately before or after the delimiter. | Normalize the source or wrap the extracted result in TRIM when those spaces are not meaningful. |
| TEXTBEFORE is unavailable | The Excel version predates the TEXTBEFORE dynamic-array function. | Use the Google Sheets-style split approach where supported or a legacy LEFT and FIND formula. |
When not to use this formula
- Do not use this formula when every delimited segment is needed; use a split formula to return the complete list.
Alternatives
| Alternative | When to use it |
|---|---|
| Split Text Formula | Use when all delimiter-separated segments should be returned. |
| Extract Text After Character | Use when the required value is after the delimiter rather than before it. |
Related formulas
Official references
- TEXTBEFORE function from Microsoft
FAQ
Which delimiter does the formula use?
The formula uses the exact character supplied as its second argument, and the shown version returns text before the first occurrence.
What if the delimiter is missing?
The shown formula produces an error; add an IFERROR fallback when a missing delimiter is an expected input case.