# TEXTBEFORE formula generator

> Describe what you need and get a TEXTBEFORE formula for Excel and Google Sheets, run on real data before you copy it. Plus 8 tested TEXTBEFORE examples.

Source: https://spreadsheetpractice.com/tools/formula-generator/textbefore · Updated October 29, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

TEXTBEFORE returns everything before a delimiter you name, such as the username before the @ in an email or the first name before a space.

Describe the task at [TEXTBEFORE formula generator](https://spreadsheetpractice.com/tools/formula-generator/textbefore) and get a TEXTBEFORE formula for Excel and Google Sheets, tested on real data.

## Tested TEXTBEFORE examples

### Extract characters from the middle of a text string

`=MID(A2,$E$1,$G$1)`

Excel. Result on the sample sheet: 5 rows (B2:B6). [See it and try it](https://spreadsheetpractice.com/formulas/extract-characters-from-middle)

### Extract the first name from a full name

`=TEXTBEFORE(A2," ")`

Excel. Result on the sample sheet: 6 rows (B2:B7). [See it and try it](https://spreadsheetpractice.com/formulas/extract-first-name)

### Extract text before a character

`=TEXTBEFORE(A2,$E$1)`

Excel. Result on the sample sheet: 6 rows (B2:B7). [See it and try it](https://spreadsheetpractice.com/formulas/extract-text-before-a-character)

### Convert a score like 18/20 to a percentage

`=TEXTBEFORE(B2,"/")/TEXTAFTER(B2,"/")`

Excel. Result on the sample sheet: 5 rows (C2:C6). [See it and try it](https://spreadsheetpractice.com/formulas/convert-a-score-to-a-percentage)

### Convert text like 12 kg to a number

`=VALUE(TEXTBEFORE(A2," "))*IF(TEXTAFTER(A2," ")="g",0.001,1)`

Excel. Result on the sample sheet: 6 rows (B2:B7). [See it and try it](https://spreadsheetpractice.com/formulas/convert-text-with-units-to-numbers)

## Questions

### What does the TEXTBEFORE formula generator do?

You describe the task in plain English, and it writes the formula, using TEXTBEFORE where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.

### What does TEXTBEFORE do?

TEXTBEFORE returns everything before a delimiter you name, such as the username before the @ in an email or the first name before a space.

### Can I learn to write TEXTBEFORE formulas myself?

Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the TEXTBEFORE function page has a practice exercise.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
