Skip to main content

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

Excel formula
=TEXTBEFORE(A2, "-")
Google Sheets formula
=INDEX(SPLIT(A2, "-"), 1, 1)
Excel / Google Sheets difference

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 TextExample Result
Maya ChenMaya
SKU-1001-EastSKU
https://www.example.com/pricingexample.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 pieceRole in the formula
A2The source text, such as SKU-1001-East.
"-"The delimiter that marks where the returned prefix ends.
First segmentThe shown formulas return the text before the first matching delimiter.

Verified examples

Extract SKU prefix in Excel
=TEXTBEFORE(A2, "-")

Excel: Enter SKU-1001-East in A2. Returns: SKU

Extract SKU prefix in Google Sheets
=INDEX(SPLIT(A2, "-"), 1, 1)

Google Sheets: Enter SKU-1001-East in A2. Returns: SKU

Use a pipe delimiter
=TEXTBEFORE(A2, "|")

Excel: Enter ABC|West in A2. Returns: ABC

Common errors and fixes

IssueLikely causeFix
The formula returns an error for a row without the delimiterTEXTBEFORE 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 spaceThe 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 unavailableThe 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

AlternativeWhen to use it
Split Text FormulaUse when all delimiter-separated segments should be returned.
Extract Text After CharacterUse when the required value is after the delimiter rather than before it.

Related formulas

Official references

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.