Syntax
=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])Arguments
| Argument | Required | Description |
|---|---|---|
text | Required | The text to search |
delimiter | Required | The text that marks the point to cut at (an array gives several delimiters) |
instance_num | Optional | Which delimiter to use, from 1 (negative counts from the end; 1 when left out) |
match_mode | Optional | 0 match case (default), 1 ignore case |
match_end | Optional | 1 treats the end of the text as a delimiter |
if_not_found | Optional | The result when there is no match (#N/A when left out) |
How to use TEXTBEFORE
TEXTBEFORE takes 2 required arguments and 4 optional arguments. Type =TEXTBEFORE( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=TEXTBEFORE("Little Red Riding Hood", " ")Result =TEXTBEFORE("Little Red Riding Hood", " ", -1)Result =TEXTBEFORE("abc", "x")Result Related text functions
- SUBSTITUTEReplaces existing text with new text, everywhere or only in one occurrence.
- TReturns the value if it is text, otherwise empty text.
- TEXTFormats a number as text with a number format code, like "$#,##0.00" or "yyyy-mm-dd".
- TEXTAFTERReturns the text that comes after a delimiter.
- TEXTJOINJoins texts and ranges with a delimiter between them, optionally skipping empty values.
- TEXTSPLITSplits text into columns and rows at the delimiters you give.
- TO_DATEReturns a number as a date value (the number itself; text and other values are returned unchanged).
- TO_DOLLARSReturns a number as a currency value (the number itself; other values are returned unchanged).
- TO_PERCENTReturns a number as a percentage value (the number itself; other values are returned unchanged).