Text function
Excel MID function
MID returns a chunk of text from the middle of a string. You tell it where to start and how many characters to take. Use it to pull a year out of an order ID or a middle section from a code.
=MID(text, start_num, num_chars)Arguments
text- The text or cell to take characters from.
start_num- The position of the first character you want. The first character is 1.
num_chars- How many characters to return.
MID examples
Every result below was calculated live from this sample sheet.
| A | B | C | |
|---|---|---|---|
| 1 | Order ID | Customer | |
| 2 | ORD-2025-00871 | kim.lee@harbor.io | Kim Lee |
| 3 | ORD-2024-01934 | p.nash@delta.com | Pat Nash |
| 4 | ORD-2025-00042 | mo@sunrise.co | Mo Ali |
Result: 2025
Starts at character 5 and takes 4: the year "2025".
Result: 01934
Jumps past "ORD-2024-" to return the sequence number "01934".
Result: harbor.io
Everything after the @ sign: the email domain. A large count just takes the rest.
Result: 42
MID returns text, so VALUE turns "00042" into the number 42.
How to use MID
- Find the position where your piece starts. Count from 1, or use FIND.
- Type =MID( and select the text cell.
- Add the start position, then the number of characters.
- Close the bracket.
Common MID mistakes
Counting from 0
Excel counts the first character as 1. MID(A2,0,3) returns #VALUE!.
Forgetting the third argument
Unlike LEFT and RIGHT, MID needs num_chars. Use a big number like 100 to take the rest of the text.
Fixed positions on uneven data
If the pieces move around, find the start with FIND or SEARCH instead of hard-coding it.
MID FAQ
How do I extract text between two characters in Excel?
Find both positions and subtract: =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1) returns what is inside the brackets.
How do I get the email domain in Excel?
Use =MID(A2,FIND("@",A2)+1,100). It starts right after the @ and takes everything to the end.
What happens if num_chars goes past the end of the text?
Nothing bad. MID just returns the characters up to the end, so a big number is a safe way to say "the rest".
Guides that use MID
- How to separate first and last name in Excel
- How to extract text before a character in Excel
- How to capitalize the first letter in Excel
- How to remove characters from a cell in Excel
- How to extract numbers from a string in Excel
- Excel formulas cheat sheet: the 25 everyone should know
Related functions
LEFTCharacters from the startRIGHTCharacters from the endFINDPosition of text (case-sensitive)LENLength of text
Updated 2026-10-31