Text formula
LEFT / RIGHT / MID in Excel and Google Sheets
Extract characters from the start, end or middle of text.
Syntax
=LEFT(text, n) =RIGHT(text, n) =MID(text, start, n)- text
- The text or cell.
- n
- Number of characters.
- start
- Position to start from (MID).
Example
| Row | A | B |
|---|---|---|
| 1 | Order | Year |
| 2 | 2027-INV-0042 |
B2 =LEFT(A2,4)
Result: 2027
Takes the first four characters.
Ready-to-copy formulas
Last 4 digits
=RIGHT(A2,4)Text before a dash
=LEFT(A2,FIND("-",A2)-1)
Tips
- Results are text. Wrap in VALUE() to get a number.
Need the whole spreadsheet?
Start from a free template with every formula already in place. Opening a template uses no credits.