MID function in Excel
MID returns characters from the middle of a text, starting at a position you give.
MID is the third member of the cutting family. LEFT takes from the start and RIGHT from the end. MID takes from anywhere: "start at character 4 and give me 2".
Syntax
=MID(text, start_num, num_chars)| Argument | What it is |
|---|---|
text | The text, or a cell that holds it. |
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. |
Examples
Each result below is what Excel itself showed for the formula on the sample sheet.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Full name | Code | Amount as text | |
| 2 | asha verma | asha.verma@example.com | PB-10-1234 | 1,250 |
| 3 | RAVI KUMAR | ravi@example.org | DL-08-0042 | 300 |
| 4 | meena gill | meena.gill@example.com | MH-12-9876 | 45.50 |
| 5 | Kabir Khan | kabir@example.net | RJ-14-0007 | 12 kg |
=MID(C2,4,2)Result: 10From the code PB-10-1234: start at the 4th character and take 2, the district number.
=MID(C2,7,4)Result: 1234Start at the 7th character and take 4: the serial number.
=MID(B2,FIND(".",B2)+1,FIND("@",B2)-FIND(".",B2)-1)Result: vermaThe part of the email between the first dot and the @: the surname.
=MID(A3,FIND(" ",A3)+1,100)Result: KUMAREverything after the first space. A large number such as 100 means "to the end".
=MID(C2,4,2)+0Result: 10Adding zero turns the text "10" into the number 10.
=MID(C2,20,3)Result: (empty)Starting beyond the end of the text returns empty text, not an error.
How it works
MID needs three things: the text, where to start, and how many characters to take. Counting starts at 1 for the first character. Spaces and punctuation are counted.
All three arguments are required. Unlike LEFT and RIGHT, MID has no default length.
To the end of the text
If you want everything from a starting point onwards and do not know how long the text is, give a number that is certainly large enough, such as 100 or 1000. MID stops at the end of the text and does not pad the result. The fourth example uses this to take the surname from a name.
Finding the start
With fixed-layout codes, the positions are typed in. When the layout varies, FIND supplies the position of a marker:
- one after the marker is the start:
FIND(marker, text) + 1; - the gap between two markers, less one, is the length.
The third example cuts the piece between a dot and an @ this way. Such formulas are easier to write in steps. Put the two FIND results in helper cells first, check them, and then build the MID. Join them into one formula afterwards if you wish.
The second word, the third field
For text with several separators, such as PB-10-1234, the second FIND must start searching after the first separator. FIND's third argument sets the starting point:
- first dash:
FIND("-", A1) - second dash:
FIND("-", A1, FIND("-", A1) + 1)
Then MID takes what lies between. This gets long quickly. In Microsoft 365, TEXTSPLIT does the whole job in one function. In other versions, Text to Columns on the Data tab, or Flash Fill, is often quicker for a one-time clean-up.
One character at a time
=MID(A1, n, 1) returns the nth character. With SEQUENCE in Excel 2021 and later, =MID(A1, SEQUENCE(LEN(A1)), 1) spills every character into its own cell, which is the basis of formulas that count digits or check a code character by character.
The result is text
As with LEFT and RIGHT, digits cut out by MID are text. Convert with VALUE or by adding zero when you need a number.
Common mistakes
#VALUE!when the start is less than 1 or the length is negative. This usually means a FIND inside the formula did not find its marker.- Counting from 0. The first character is position 1.
- Using MID on a date cell. A date is stored as a number, so the characters are not what you see.
- An off-by-one slip. If the answer has an extra separator at one end, adjust the start or the length by one.
In Google Sheets
MID is the same in Google Sheets.
Related functions
Every result on this page was calculated in Microsoft Excel (version 16.0, build 20326) on 12 November 2026, not typed by hand.
This is an independent help site. It is not connected with or approved by Microsoft. Excel and Microsoft 365 are trademarks of Microsoft Corporation, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.