← All how-to recipes

How to use LEFT, MID, and RIGHT

✓ Verified in LibreOffice 25.8.7.3

Pull characters from the start, middle, or end of a text value — extract codes, initials, or fixed-width fields.

The formula

AppFormulaNotes
Excel=MID(A2,4,3)LEFT(text,n) from the start; RIGHT(text,n) from the end; MID(text,start,n) from a position.
Google Sheets=MID(A2,4,3)Identical.
LibreOffice Calc=MID(A2,4,3)Identical.

How it works

The three text-slicing functions work by position: LEFT(A2,3) takes the first 3 characters ("ABC"), RIGHT(A2,3) takes the last 3 ("XYZ"), and MID(A2,4,3) starts at character 4 and takes 3 ("123"). They count every character including spaces. The power move is combining them with FIND to slice at a delimiter rather than a fixed position — LEFT(A2,FIND("-",A2)-1) grabs everything before the first dash. On modern versions, TEXTBEFORE/TEXTAFTER read more clearly for delimiter-based extraction, but LEFT/MID/RIGHT are universal and exactly right for fixed-width data like part codes and account numbers.

Verified, not just documented

We ran =MID(A2,4,3) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 123 — exactly the expected result. Every formula here is confirmed by actually executing it.