ExcelFlux

TEXTBEFORE function

text that occurs before a given character or string.

Text · Excel 2024+

Where can you use it?

Data preparation and reporting teams. Use this group to clean, split or reformat IDs, names and descriptions before using them in reports.

Scenario in the workbook

Extract the document type before the separator even when ID lengths vary.

A worked example from the workbook

RowAB
6DocumentNew segment
7INV-042NEW
8INV-119RCV
9INV-126ARC
Record 1
=TEXTBEFORE(A7,"-")

Expected resultINV

See the inputs and instructions for all 3 examples

Copyable formulas

English Excel · en-US
=TEXTBEFORE("INV-042","-")
Turkish Excel · tr-TR
=ÖNCEKİMETİN("INV-042";"-")

Expected result

“INV”

Worked examples

Extract the document type before the separator even when ID lengths vary.

Open the English sheet. Inputs begin at A6. F7:F9 show the live results and G7:G9 show the original results for comparison.

Row A B
6 Document New segment
7 INV-042 NEW
8 INV-119 RCV
9 INV-126 ARC
Case Formula Expected result
Record 1 =TEXTBEFORE(A7,"-") INV
Record 2 =TEXTBEFORE(A8,"-") INV
Record 3 =TEXTBEFORE(A9,"-") INV
Microsoft Excel reference