Text function

Google Sheets MID function

Returns a section of text from the middle of a string, given a start position and length.

Syntax

=MID(string, starting_at, extract_length)
stringThe text to take characters from.
starting_atThe position of the first character to return (1 = the first character).
extract_lengthHow many characters to return.

Try it

Edit the formula and the result updates instantly. Click a cell to add its reference.

▦ Customer import
fx
Result: 2041
ABC
1Name (raw)Order codeCity
2 jane DOE NY-2041-ANew York
3MARK smithCA-1187-BFresno
4ana lopezTX-3302-CAustin
5li weiWA-0459-ASeattle
6 OMAR faroukFL-7720-BTampa
7sara KIMNY-5521-CBuffalo

Examples

These use the sample sheet above.

→ 2041

The 4-digit order number in the middle of the code.

→ 1187

Multiply by 1 to turn the extracted digits into a real number.

Tips & common mistakes

Related functions