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)
string | The text to take characters from. |
|---|---|
starting_at | The position of the first character to return (1 = the first character). |
extract_length | How many characters to return. |
Try it
Edit the formula and the result updates instantly. Click a cell to add its reference.
Customer import
Result: 2041
| A | B | C | |
|---|---|---|---|
| 1 | Name (raw) | Order code | City |
| 2 | jane DOE | NY-2041-A | New York |
| 3 | MARK smith | CA-1187-B | Fresno |
| 4 | ana lopez | TX-3302-C | Austin |
| 5 | li wei | WA-0459-A | Seattle |
| 6 | OMAR farouk | FL-7720-B | Tampa |
| 7 | sara KIM | NY-5521-C | Buffalo |
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
- MID always returns text. Multiply by 1 (or use VALUE in Google Sheets) to do math with the result.