Skip to content
Google Sheets

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.

  1. Characters 5–9 of an order code like NYC-10422-A — the numeric part:

    =MID(A2, 5, 5)

    Result"10422"

  2. 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.

Loading the editor…

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.