---
title: "TEXTBEFORE function in Excel: syntax and examples | PracticeExcel"
description: "How to use TEXTBEFORE in Excel 365: the first name, the user name in an email, or everything before the last slash, with examples."
canonical_url: "https://practiceexcelonline.com/functions/textbefore"
locale: en
meta:
  "og:description": "How to use TEXTBEFORE in Excel 365: the first name, the user name in an email, or everything before the last slash, with examples."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~VEVYVEJFRk9SRSBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBURVhUQkVGT1JFIGluIEV4Y2VsIDM2NTogdGhlIGZpcnN0IG5hbWUsIHRoZSB1c2VyIG5hbWUgaW4gYW4gZW1haWwsIG9yIGV2ZXJ5dGhpbmcgYmVmb3JlIHRoZSBsYXN0IHNsYXNoLCB3aXRoIGV4YW1wbGVzLg%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~VEVYVEJFRk9SRSh0ZXh0LCBkZWxpbWl0ZXIsIFtpbnN0YW5jZV9udW1dLCBbbWF0Y2hfbW9kZV0sIFttYXRjaF9lbmRdLCBbaWZfbm90X2ZvdW5kXSk%2Cp_Ii9mdW5jdGlvbnMvdGV4dGJlZm9yZSI%2Cs_18uZ2-iwcRnYY2dm.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "TEXTBEFORE function in Excel: syntax and examples | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~VEVYVEJFRk9SRSBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBURVhUQkVGT1JFIGluIEV4Y2VsIDM2NTogdGhlIGZpcnN0IG5hbWUsIHRoZSB1c2VyIG5hbWUgaW4gYW4gZW1haWwsIG9yIGV2ZXJ5dGhpbmcgYmVmb3JlIHRoZSBsYXN0IHNsYXNoLCB3aXRoIGV4YW1wbGVzLg%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~VEVYVEJFRk9SRSh0ZXh0LCBkZWxpbWl0ZXIsIFtpbnN0YW5jZV9udW1dLCBbbWF0Y2hfbW9kZV0sIFttYXRjaF9lbmRdLCBbaWZfbm90X2ZvdW5kXSk%2Cp_Ii9mdW5jdGlvbnMvdGV4dGJlZm9yZSI%2Cs_18uZ2-iwcRnYY2dm.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **The TEXTBEFORE function**

Returns the text before a delimiter, such as everything before the @ in an email address. You can choose which occurrence of the delimiter to use.

=

TEXTBEFORE(

## **Syntax**

```
TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
```

<dl><dt>**text **</dt>
<dd>The text to search.</dd>
<dt>**delimiter **</dt>
<dd>The character or text to stop at.</dd>
<dt>**instance_num **(optional)</dt>
<dd>Which occurrence to use. 1 or left out for the first, 2 for the second, -1 for the last.</dd>
<dt>**match_mode **(optional)</dt>
<dd>1 to ignore upper and lower case. Left out, 0, which matches case.</dd>
<dt>**match_end **(optional)</dt>
<dd>1 to treat the end of the text as a delimiter. Left out, 0.</dd>
<dt>**if_not_found **(optional)</dt>
<dd>What to return when the delimiter is missing. Left out,</dd></dl>

## **Examples**

C1`=TEXTBEFORE(<sup>1</sup>A2,<sup>2</sup>"@")`

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Email |  | **ann.berg** |
| 2 | ann.berg@example.com |  | |

**In plain words:** Return the text in <sup>1</sup>the email address in A2 that comes <sup>2</sup>before the @.

B1=TEXTBEFORE("2024-03-15","-",2)

|  | A | B |
| --- | --- | --- |
| 1 |  | **2024-03** |

B1=TEXTBEFORE("C:/Reports/2024/sales.xlsx","/",-1)

|  | A | B |
| --- | --- | --- |
| 1 |  | **C:/Reports/2024** |

## **Practice TEXTBEFORE**

- [**1****Take the first name with TEXTBEFORE**→](https://practiceexcelonline.com/practice/substitute-textbefore-textafter/textbefore-first-name)
- [**2****Flip "Last, First" with TEXTAFTER**→](https://practiceexcelonline.com/practice/substitute-textbefore-textafter/textafter-flip-names)
- [**3****Take the text between parentheses**→](https://practiceexcelonline.com/practice/substitute-textbefore-textafter/text-between-parentheses)

## **Questions**

<details>

<summary>

### Why does TEXTBEFORE return

</summary>

The delimiter is not in the text. Give a fallback as the last argument, as in =TEXTBEFORE(A2," ",,,,A2), to return the whole text when there is no space.

</details>

<details>

<summary>

### How do I do the same in older versions of Excel?

</summary>

Combine LEFT and FIND, as in =LEFT(A2,FIND("@",A2)-1). FIND gives the position of the @, and LEFT takes everything before it.

</details>

## **Related functions**

- [**TEXTAFTER**](https://practiceexcelonline.com/functions/textafter)
- [**TEXTSPLIT**](https://practiceexcelonline.com/functions/textsplit)
- [**LEFT**](https://practiceexcelonline.com/functions/left)
- [**FIND**](https://practiceexcelonline.com/functions/find)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/functions/textbefore#webpage","description":"How to use TEXTBEFORE in Excel 365: the first name, the user name in an email, or everything before the last slash, with examples.","name":"TEXTBEFORE function in Excel: syntax and examples","url":"https://practiceexcelonline.com/functions/textbefore","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://practiceexcelonline.com/functions/textbefore#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"mainEntity":[{"@id":"https://practiceexcelonline.com/functions/textbefore#/schema/question/1"},{"@id":"https://practiceexcelonline.com/functions/textbefore#/schema/question/2"}],"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/functions/textbefore"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/functions/textbefore#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://practiceexcelonline.com/functions","position":2},{"@type":"ListItem","name":"TEXTBEFORE function in Excel: syntax and examples","position":3}]},{"@id":"https://practiceexcelonline.com/functions/textbefore#article","description":"How to use TEXTBEFORE in Excel 365: the first name, the user name in an email, or everything before the last slash, with examples.","headline":"TEXTBEFORE function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~VEVYVEJFRk9SRSBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBURVhUQkVGT1JFIGluIEV4Y2VsIDM2NTogdGhlIGZpcnN0IG5hbWUsIHRoZSB1c2VyIG5hbWUgaW4gYW4gZW1haWwsIG9yIGV2ZXJ5dGhpbmcgYmVmb3JlIHRoZSBsYXN0IHNsYXNoLCB3aXRoIGV4YW1wbGVzLg%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~VEVYVEJFRk9SRSh0ZXh0LCBkZWxpbWl0ZXIsIFtpbnN0YW5jZV9udW1dLCBbbWF0Y2hfbW9kZV0sIFttYXRjaF9lbmRdLCBbaWZfbm90X2ZvdW5kXSk%2Cp_Ii9mdW5jdGlvbnMvdGV4dGJlZm9yZSI%2Cs_18uZ2-iwcRnYY2dm.png","@type":["Article","TechArticle"],"author":{"@id":"https://practiceexcelonline.com/#identity"},"image":{"@id":"https://practiceexcelonline.com/#/schema/image/1"},"isPartOf":{"@id":"https://practiceexcelonline.com/functions/textbefore#webpage"},"mainEntityOfPage":{"@id":"https://practiceexcelonline.com/functions/textbefore#webpage"},"publisher":{"@id":"https://practiceexcelonline.com/#identity"}},{"@id":"https://practiceexcelonline.com/functions/textbefore#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"Why does TEXTBEFORE return","acceptedAnswer":{"@type":"Answer","text":"The delimiter is not in the text. Give a fallback as the last argument, as in =TEXTBEFORE(A2,\" \",,,,A2), to return the whole text when there is no space."}},{"@id":"https://practiceexcelonline.com/functions/textbefore#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"How do I do the same in older versions of Excel?","acceptedAnswer":{"@type":"Answer","text":"Combine LEFT and FIND, as in =LEFT(A2,FIND(\"@\",A2)-1). FIND gives the position of the @, and LEFT takes everything before it."}},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"},{"@id":"https://practiceexcelonline.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~VEVYVEJFRk9SRSBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBURVhUQkVGT1JFIGluIEV4Y2VsIDM2NTogdGhlIGZpcnN0IG5hbWUsIHRoZSB1c2VyIG5hbWUgaW4gYW4gZW1haWwsIG9yIGV2ZXJ5dGhpbmcgYmVmb3JlIHRoZSBsYXN0IHNsYXNoLCB3aXRoIGV4YW1wbGVzLg%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~VEVYVEJFRk9SRSh0ZXh0LCBkZWxpbWl0ZXIsIFtpbnN0YW5jZV9udW1dLCBbbWF0Y2hfbW9kZV0sIFttYXRjaF9lbmRdLCBbaWZfbm90X2ZvdW5kXSk%2Cp_Ii9mdW5jdGlvbnMvdGV4dGJlZm9yZSI%2Cs_18uZ2-iwcRnYY2dm.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~VEVYVEJFRk9SRSBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBURVhUQkVGT1JFIGluIEV4Y2VsIDM2NTogdGhlIGZpcnN0IG5hbWUsIHRoZSB1c2VyIG5hbWUgaW4gYW4gZW1haWwsIG9yIGV2ZXJ5dGhpbmcgYmVmb3JlIHRoZSBsYXN0IHNsYXNoLCB3aXRoIGV4YW1wbGVzLg%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~VEVYVEJFRk9SRSh0ZXh0LCBkZWxpbWl0ZXIsIFtpbnN0YW5jZV9udW1dLCBbbWF0Y2hfbW9kZV0sIFttYXRjaF9lbmRdLCBbaWZfbm90X2ZvdW5kXSk%2Cp_Ii9mdW5jdGlvbnMvdGV4dGJlZm9yZSI%2Cs_18uZ2-iwcRnYY2dm.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
