MID Function
Returns characters from the middle of a text value, starting at a position you choose.
Category
Text
Available in
All versions, Microsoft 365
Returns
Text
Overview
MID extracts a chunk from inside a text string. You give it a starting position and how many characters to take.
It's ideal for codes with a fixed layout, and with FIND it can pull out whatever sits between two markers.
Syntax
=MID(text, start_num, num_chars) Explain
Arguments
| Argument | Required? | What it does |
|---|---|---|
| text | Yes | The text to extract from. |
| start_num | Yes | The position of the first character you want. The first character is 1. |
| num_chars | Yes | How many characters to return. |
Examples
Example 1 — Product number from the middle of a SKU
Northstar's SKUs look like NS-1042-BLU. The product number always starts at character 4 and is 4 long.
B2fx=MID(A2, 4, 4)
| A | B | |
|---|---|---|
| 1 | SKU | Product |
| 2 | NS-1042-BLU | 1042 |
| 3 | NS-2210-RED | 2210 |
| 4 | NS-0087-GRN | 0087 |
=MID(A2, 4, 4) Explain
Example 2 — Text between two brackets
Pull the department out of each invoice description.
B2fx=MID(A2, FIND("[", A2)+1, FIND("]", A2)-FIND("[", A2)-1)
| A | B | |
|---|---|---|
| 1 | Description | Department |
| 2 | INV-1001 [Sales] | Sales |
| 3 | INV-1002 [Marketing] | Marketing |
| 4 | INV-1003 [IT] | IT |
=MID(A2, FIND("[", A2)+1, FIND("]", A2)-FIND("[", A2)-1) Explain
- Start one character after the opening bracket.
- The length is the gap between the two brackets, minus one.
- MID returns just the text inside.
In Microsoft 365, =TEXTBEFORE(TEXTAFTER(A2, "["), "]") reads more naturally.
Common mistakes
- start_num below 1. MID returns #VALUE! if start_num is 0 or negative — common when a FIND result is off by one.
- Text, not numbers. "0087" is text. Use --MID(…) or VALUE when you need to calculate with it.
Notes
- If start_num is past the end of the text, MID returns empty text rather than an error.
- Related functions: LEFT, RIGHT, FIND, TEXTBEFORE, TEXTAFTER.

Author
Kyle Stott
Certified Microsoft Excel Expert
Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.