Text

MID Formula

MID extracts a substring from the middle of a text string, starting at a position you specify and for a given number of characters. It is essential when you need characters from a specific position, like extracting a state code from the middle of an address string or pulling digits from a formatted ID number.

Syntax

MID(text, start_num, num_chars)
ParameterDescription
text Parameter of the MID function.
start_num Parameter of the MID function.
num_chars Parameter of the MID function.
Try MID in Viztab — free, no signup

Examples

Extract middle portion of a product code

Formula
=MID(A2, 4, 3)
Returns: "456" — 3 characters starting at position 4 from "ABC456-XY"

Get month from a date string

Formula
=MID(A2, 6, 2)
Returns: "03" — the month portion from "2024-03-15"

Extract area code from formatted phone

Formula
=MID(A2, 2, 3)
Returns: "212" — from "(212) 555-1234", starting at position 2 for 3 characters

Common Errors

#VALUE!

Start position or num_chars is negative or zero. Start must be >= 1 and num_chars >= 0.

#VALUE!

The cell is a number, not text. Convert first: =MID(TEXT(A1, "0"), 3, 2).

Tips

Dynamic start with FIND

=MID(A1, FIND("-",A1)+1, 3) extracts 3 characters after the first hyphen.

Extract between delimiters

Combine FIND and MID to extract text between two markers, e.g., between parentheses or brackets.

Safe over-extraction

If num_chars exceeds the remaining text length, MID just returns what is available — it does not error.

Try MID in Viztab

Import your data and use MID with 370+ other formulas. No signup required.

Open Viztab

Related Formulas