# MID function in Excel

> MID returns characters from the middle of a text string, starting at a position you choose.

Source: https://spreadsheetpractice.com/functions/mid · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

## Quick answer

- **What it does:** MID returns characters from the middle of a text string, starting at a position you choose.
- **Syntax:** `=MID(text, start_num, num_chars)`
- **Most common use:** `=MID(A2,5,4)` returns 2026 (The year: four characters starting at position 5)
- **Available in:** Every current version
- **Category:** [Text functions](https://spreadsheetpractice.com/functions/category/text)
- **Returns:** Text. If start_num is past the end of the text, an empty string.
- **Google Sheets:** Works the same in Google Sheets.

## What it does

MID returns characters from the middle of a text string, starting at a position you choose. Use it for fixed-format codes where the piece you want sits in the same place every time, like the year in INV-2026-0042.

## Syntax

`=MID(text, start_num, num_chars)`

| Argument | Required? | What it is |
|---|---|---|
| `text` | Required | The text or cell to read from. |
| `start_num` | Required | Position of the first character to return. The first character in the text is 1. |
| `num_chars` | Required | How many characters to return. |

## Examples

Each result was calculated by running the formula on the sample sheet.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| D2 | `=MID(A2,5,4)` | 2026 | The year: four characters starting at position 5 |
| D3 | `=MID(B3,3,6)` | 888BB2 | Characters 3 through 8 of a tracking number |
| D4 | `=MID(C4,FIND("-",C4)+1,3)` | GRN | The color code, starting just after the first dash |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C | D |
|---|---|---|---|---|
| 1 | Invoice | Tracking number | Product code | Result |
| 2 | INV-2026-0042 | 1Z999AA10123456784 | WDG-BLU-L | 2026 |
| 3 | INV-2025-1187 | 1Z888BB20234567891 | GDT-RED-M | 888BB2 |
| 4 | INV-2026-0310 | 1Z777CC30345678912 | GZM-GRN-S | GRN |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| Off by one | start_num counts from 1, and the delimiter takes a position too: in NY-2026 the year starts at 4, not 3. Use FIND("-",A2)+1 to start right after a dash. |
| The result won't add up | MID returns text, so MID(A2,5,4) gives "2026", which SUM skips and lookups treat as text. Add 0 or wrap it in VALUE. |
| Pieces vary in length | A fixed num_chars cuts variable-length parts short. Locate both delimiters with FIND, or use TEXTBEFORE and TEXTAFTER. |

## Tips

- Ask for more characters than you need and MID stops at the end of the text: =MID(A2,5,99) returns everything from position 5 on.

## Related functions

- [LEFT](https://spreadsheetpractice.com/functions/left): LEFT returns a set number of characters from the start of a text string.
- [RIGHT](https://spreadsheetpractice.com/functions/right): RIGHT returns a set number of characters from the end of a text string.
- [FIND](https://spreadsheetpractice.com/functions/find): FIND returns the position of one piece of text inside another, counting from 1.
- [TEXTAFTER](https://spreadsheetpractice.com/functions/textafter): TEXTAFTER returns everything after a delimiter, such as the domain after the @ or the last part of a file path.

## Questions

### How do I extract text between two characters in Excel?

In Excel 2024 or Microsoft 365, nest the split functions: =TEXTBEFORE(TEXTAFTER(A2,"-"),"-") returns the text between the first two dashes. In older versions, use MID with FIND to calculate the start and length.

### Does Excel have a SUBSTRING function?

No. MID is the equivalent: give it the text, a start position and a length.

## Practice

A graded MID exercise ("Year from the middle") is on [the MID page](https://spreadsheetpractice.com/functions/mid). It is checked instantly, then re-checked on changed data.

Lessons that use MID:

- [Lesson 18: LEFT, RIGHT, MID & LEN](https://spreadsheetpractice.com/learn/left-right-mid-len) (Pro)

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
