MID Function
The Excel MID function extracts a specified number of characters from inside text. It uses a one-based starting position and returns empty text when that position is beyond the source.
| Excel MID Function | |||||||
| MID extracts characters from inside text using a start position and length. | |||||||
| Text scenarios, editable | MID examples | ||||||
| Scenario | Source text | Start | Characters | Example | Formula syntax | Result | |
| Year segment | INV-2026-041 | 5 | 4 | Year segment | =MID(B12,C12,D12) | 2026 | |
| Last name | Maya Chen | 6 | 4 | Last name | =MID(B13,C13,D13) | Chen | |
| Month segment | 2026-Aug-15 | 6 | 3 | Month segment | =MID(B14,C14,D14) | Aug | |
| Single character | ABC123 | 4 | 1 | Single character | =MID(B15,C15,D15) | 1 | |
| Start beyond text | Short | 10 | 3 | Start beyond text | =MID(B16,C16,D16) | ||
| How MID behaves | |||||||
| MID counts the first character as position 1, not position 0. | |||||||
| The third argument controls the maximum number of characters returned. | |||||||
| A start position beyond the end of the source returns empty text. | |||||||
| Reliability checks | |||||||
| Year-segment example returns the expected four characters | OK | ||||||
| Start position beyond the source returns empty text | OK | ||||||
Overview
The Excel MID function extracts characters from inside a text value. You specify where extraction begins and how many characters Excel should return.
Quick reference
Syntax: =MID(text, start_num, num_chars)
Returns: The requested characters as text, or empty text when the start is beyond the source. (text)
Arguments:
text(required) — The text value or cell reference containing the desired substring.start_num(required) — The one-based position of the first character to return.num_chars(required) — The maximum number of characters to return.
All three arguments are required. Character positions begin at 1, and num_chars determines the maximum number of characters returned from that starting position.
Common uses
- Extract internal segments from fixed-format identifiers.
- Return a year, month, or code component stored as text.
- Read one character from a known position.
- Split consistently structured labels without delimiter searches.
Calculations
MID counts characters from left to right, beginning with position 1. start_num identifies the first returned character, while num_chars controls the maximum length of the result.
Spaces and punctuation occupy positions just like letters and digits. If the requested length extends beyond the end of the source, Excel returns only the remaining characters. If start_num is beyond the source length, the result is empty text.
The result is text even when the extracted substring contains only digits. Fixed positions work well for stable identifiers, but become unreliable when components or delimiters move between rows.
Function behavior
Situation | Behavior |
|---|---|
First character | Uses position |
Spaces and punctuation | Count as character positions. |
Requested length exceeds remainder | Returns all available characters from the start position. |
Start exceeds text length | Returns empty text. |
| Returns |
Negative | Returns |
Common errors
Counting positions from zero
What happens:
Extraction begins one character earlier than intended or returns #VALUE! when zero is used.
Better approach:
Count the first source character as position 1.
Confusing start position with character count
What happens:
The formula starts or ends in the wrong place.
Better approach:
Treat start_num as the location and num_chars as the length.
Using fixed positions for variable text
What happens:
The desired component shifts when preceding text changes length.
Better approach:
Use FIND or SEARCH with extraction logic, or a delimiter-aware modern function where supported.
Example
Example 1 — Extract a Year Segment
=MID(B12,C12,D12)
The source is INV-2026-041, the start position is 5, and the count is 4. The result is 2026.
Example 2 — Extract a Name Component
=MID(B13,C13,D13)
Starting at position 6 in Maya Chen and returning four characters produces Chen.
Example 3 — Extract a Month Label
=MID(B14,C14,D14)
The formula starts at character 6 in 2026-Aug-15 and returns three characters: Aug.
Example workbook
The workbook contains MID Example and Notes tabs. Five examples extract a year, surname, month label, single character, and an empty result beyond the source. Two checks validate the year and beyond-end cases.
Key takeaway
MID uses a one-based start position plus a character count, making it reliable when internal text occupies stable positions.