Function · Text

Excel MID function

The Excel MID function returns characters from the middle of a text value. Characters 5 through 7 of 512-555-0148 are 555.

All current Excel versions. Also in Excel for the web and Google Sheets.

Syntax =MID(text, start_num, num_chars)

MID
=MID("512-555-0148",5,3)

Arguments

NameRequiredWhat to pass
textRequiredThe text to slice.
start_numRequiredWhere to start. The first character is 1, not 0.
num_charsRequiredHow many characters to return.

Examples

The exchange in a hyphenated US phone number

=MID(B1,5,3)

Result 555

=MID(B1,5,3)B2
Phone
AB
1Phone512-555-0148
2Exchange555
A picture of the sheet, not a live calculator. Character 4 is the hyphen. Characters 5 through 7 are 555.

MID takes a run of characters that is neither the start nor the end. In 512-555-0148, position 1 is 5, position 4 is the hyphen, and positions 5 through 7 are 555. LEFT would need the area code. RIGHT would need the last four. MID is the middle.

The start is 1-based. A start of 0 is a #VALUE! error. If the phone number gains parentheses, every position shifts and a hard-coded 5 is wrong. FIND the hyphen, add 1, and pass that to MID when the punctuation is not stable.