Excel function · Finding text
MID
Returns characters from the middle of a text.
What it does
MID takes characters from inside a text: you give the position to start at and how many characters to take.
Syntax
=MID(text, start_num, num_chars)Arguments in square brackets are optional, and … means you can add more of the same. In this Excel language, arguments are separated by ,
Arguments
- text
- The text to take characters from.
- start_num
- The position of the first character to take. The first character of the text is 1.
- num_chars
- How many characters to take from there.
Example
Order codes have a prefix, a number and a region. What is the number part of ORD-7731-EU?
| A | B | |
|---|---|---|
| 1 | Order no. | Number part |
| 2 | ORD-7731-EU | 7731 |
The formula in B2:
=MID(A2,5,4)Result: 7731
ORD- takes up four characters, so the number starts at character 5. Taking four characters from there gives 7731.
Common mistakes
- Starting one character too early or too late. Count the separator too: the hyphen is character 4 here.
- Leaving out the number of characters. Unlike
LEFTandRIGHT,MIDneeds all three arguments.
In other Excel languages
Excel translates function names, and in some languages the argument separator too. Type the name your Excel shows.
| Excel language | Function name | Separator |
|---|---|---|
| English | MID | , |
| Deutsch | TEIL | ; |
| Français | STXT | ; |
| Español (España) | EXTRAE | ; |
| Español (México) | EXTRAE | , |
| 日本語 | MID | , |
| 한국어 | MID | , |
| 繁體中文 | MID | , |
| ไทย | MID | , |
| ខ្មែរ | MID | , |
| Tiếng Việt | MID | ; |