MID function in Google Sheets
Returns a segment of a string.
=MID(string, starting_at, extract_length)MID syntax and parameters
Three arguments, three required.
- stringstringRequired
The string to extract a segment from.
- starting_atnumberRequired
The index from the left of string from which to begin extracting. The first character in string has the index 1.
- extract_lengthnumberRequired
The length of the segment to extract. If the end of string is reached before extract_length characters are encountered, MID returns the characters from starting_at to the end of string.
MID examples
Formulas you'll actually reuse.
Characters 5–9 of an order code like NYC-10422-A — the numeric part:
=MID(A2, 5, 5)Result
"10422"The segment between the first and second hyphen, whatever its length:
=MID(A2, FIND("-", A2) + 1, FIND("-", A2, FIND("-", A2) + 1) - FIND("-", A2) - 1)Result
"10422"
MID in Excel
Same name — your formula ports as-is.
Try MID in the playground
Edit the example — nothing to install.
Preloaded with the MID formula from Example 1 — change anything and watch it respond.
MID errors
What they mean — and the fixes.
#VALUE!The start position is less than 1 or the length is negative — both must be positive whole numbers.
Related functions
More ways Google Sheets gets this done.
- ARABICComputes the value of a Roman numeral.TextExcel
- CHARConvert a number into a character according to the current Unicode table.TextExcel
- CLEANReturns the text with the non-printable ASCII characters removed.TextExcel
- CODEReturns the numeric Unicode map value of the first character in the string provided.TextExcel
- CONCATENATEAppends strings to one another.TextExcel
- DOLLARFormats a number into the locale-specific currency format.TextExcel