DIRECT
Use TEXTBEFORE in current Excel
If A2 contains INV-2026-104, the delimiter is a hyphen and the first segment is the value before that delimiter.
Return the text before the first hyphen
=TEXTBEFORE(A2,"-")Replace the hyphen with the delimiter your data uses. A delimiter can contain more than one character, so inspect a few source rows before filling the formula down.
COMPATIBLE
Use LEFT and FIND in older Excel
Older-version fallback that keeps rows without a hyphen
=IFERROR(LEFT(A2,FIND("-",A2)-1),A2)FIND returns the position of the first hyphen. Subtracting one gives LEFT the number of characters to keep. Here IFERROR has one defined job: if the delimiter is absent, return the original cell.
CHECK
Decide what should happen at the edges
- • Multiple hyphens: both examples return the segment before the first one.
- • Leading spaces: wrap the result in TRIM only if those spaces are not meaningful.
- • Missing delimiter: choose between the original value, a blank, or a review flag.
- • Version support: TEXTBEFORE is not available in every perpetual Excel release.
SOURCE