The Excel MID function extracts characters from the middle of a text string: tell it where to start and how many to take. Where LEFT and RIGHT only work the ends, MID reaches anywhere — the segment between two hyphens, the area code inside a phone number, the year buried in an ID. Paired with FIND, it extracts pieces whose position changes from row to row.
Syntax
| Argument | Description | |
|---|---|---|
text | Required | The text string (or cell reference) to extract from. |
start_num | Required | Position of the first character to take. Counting starts at 1. Must be 1 or greater; past the end of the string, MID returns "". |
num_chars | Required | How many characters to return. Zero or positive. If it runs past the end of the string, MID returns what it can — no error. |
Available in: every version of Excel. Unlike LEFT and RIGHT, neither numeric argument is optional — all three must be supplied. The result is always text.
Pull a fixed middle segment
These SKUs always carry a three-letter plant code in positions 4–6. One formula in B2, filled down, lifts it out:
| A | B | |
|---|---|---|
| 1 | SKU | Plant code |
| 2 | TX-DAL-0042 | DAL |
| 3 | TX-FTW-1187 | FTW |
| 4 | OK-TUL-0916 | TUL |
Greedy variant: a big num_chars turns MID into “everything from position N onward” — a common way to skip a fixed prefix:
Try it: interactive MID demo
Drag both sliders and watch the MID window slide across the sample string.
Dynamic middles with MID + FIND
Fixed positions break when string lengths vary. Let FIND locate the landmarks. Text between two hyphens, wherever they fall:
The inner FIND("-", A2) + 1 starts the window just past the first hyphen; the outer FIND (with its third argument) locates the second hyphen so the difference is the segment length. The same pattern grabs the middle word of three:
MID is also the classic way to split a string into single characters for character-level tricks (Excel 365):
Modern alternative: in Excel 365, TEXTSPLIT cracks delimited strings in one move — =TEXTSPLIT(A2, "-") spills every segment, no position math. Pair TEXTBEFORE + TEXTAFTER for one piece. MID remains the works-everywhere classic.
Errors & common pitfalls
#VALUE! — start_num less than 1 or negative num_chars. start_num must be at least 1 and num_chars at least 0. In MID + FIND combos the usual culprit is FIND erroring (delimiter missing) or arithmetic dipping below zero — wrap the combo in IFERROR.
Pitfall: counting starts at 1, not 0. The first character is position 1. Programmers expecting zero-based indexing get results shifted one character left… or rather, they ask for position 0 and get #VALUE!.
Pitfall: a start past the end returns "" silently. =MID("TX", 5, 3) returns an empty string, not an error. Blank results downstream often trace back to a start_num that overshot.
Pitfall: the result is text. =MID("INV-2026-X", 5, 4) returns the text "2026". Wrap in VALUE() when the digits must behave as a number, and remember dates are serial numbers under the hood — use TEXT(A2, "…") first to slice what you see.
Practice workbook
Frequently asked questions
How do I extract text between two characters with MID?
=MID(A2, FIND("-", A2) + 1, FIND("-", A2, FIND("-", A2) + 1) - FIND("-", A2) - 1) returns whatever sits between the first two hyphens. In Excel 365, =TEXTBEFORE(TEXTAFTER(A2, "-"), "-") reads far more cleanly.Are all three MID arguments really required?
What happens when num_chars runs past the end of the string?
=MID(A2, 4, 100) is a handy idiom for "everything from position 4 on."Why does MID return an empty result?
Why does MID give #VALUE!?
MID vs TEXTSPLIT - which should I use?
=TEXTSPLIT(A2, "-") spills every piece with zero math. MID is the right tool for fixed-position slices and for workbooks that must open in older Excel.Master functions like this in one day
This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class