SheetsLessons
Text function

MID function in Google Sheets

MID extracts characters from the middle of a text string, given a starting position and a length. It's the tool for structured codes where the part you need is sandwiched in between.

Syntax

=MID(string, starting_at, extract_length)
string
The text to extract from.
starting_at
Position of the first character to take (1 = first character).
extract_length
How many characters to take.

Practice MID

Task 1 of 1

Extract the 4-digit item number from the middle of the SKU. Answer in B2.

B2
fx

Tip: while typing a formula, click a cell or drag across cells to insert references. Press Enter to check, and Tab to accept a function suggestion.

MID examples

Each example below runs against this sample sheet. The results are calculated by the same engine as the practice grid.

ABC
1Raw nameSKUNote
2  maya   PATEL ELC-0427-NYRefund requested
3leo rossiFUR-1180-TXShipped
4AVA KIMOFC-0093-CARefund issued
Messy imported data
FormulaResultWhat it shows
=MID(B2, 5, 4)0427The item number inside the SKU.
=MID(B3, 5, 4)1180Same position, another row.
=VALUE(MID(B2, 5, 4))427Convert to a real number (drops the leading zero).

Tips and common mistakes

  • If extract_length runs past the end, MID just returns what's there and doesn't error.

Related functions