MID function
MID extracts characters from the middle of a text string, given a start position and a length. Pair it with FIND or SEARCH to pull out text between delimiters.
Example
Read it as a sentence: start at character 2 of abcdef and take 3 characters, which gives bcd.
A
B
C
D
1
bcd
2
3
Syntax
MID(text, start_num, num_chars)
-
text(required) - The text to extract from.
-
start_num(required) - Position of the first character to take (1 is the first).
-
num_chars(required) - How many characters to take.
Returns: The extracted substring.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=MID("Excel",2,3) | xce | Basic |
=MID("Excel",10,2) | Start past end | |
=MID("Excel",2,100) | xcel | Length past end |
=MID(12345,2,2) | 23 | Number |
=MID("Excel",1.9,2.9) | Ex | Fractional args |
=MID("Excel",0,1) | #VALUE! | Start 0 |
=MID("Excel",2,-1) | #VALUE! | Negative length |
Watch out for
- Result is text.
- A start beyond the text length returns an empty string.
Where it works
- Excel
- MID is in every version of Excel from 2007 on.
- Google Sheets
- Same name, same behaviour for everyday use.
Part of Text functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .