MID Function

Excel Functions › Text

All Excel versions Text

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.


Quick answer: to pull 3 characters starting at position 4:
=MID(A2, 4, 3)
From "TX-DAL-0042" that returns "DAL". Both position arguments are required, and counting starts at 1 — the first character is position 1, not 0.

Syntax

=MID(text, start_num, num_chars)
ArgumentDescription
textRequiredThe text string (or cell reference) to extract from.
start_numRequiredPosition of the first character to take. Counting starts at 1. Must be 1 or greater; past the end of the string, MID returns "".
num_charsRequiredHow 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:

AB
1SKUPlant code
2TX-DAL-0042DAL
3TX-FTW-1187FTW
4OK-TUL-0916TUL
=MID(A2, 4, 3) // start at character 4, take 3

Greedy variant: a big num_chars turns MID into “everything from position N onward” — a common way to skip a fixed prefix:

=MID(A2, 4, 100) // returns "DAL-0042" - everything from position 4

Try it: interactive MID demo

Live 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:

=MID(A2, FIND("-", A2) + 1, FIND("-", A2, FIND("-", A2) + 1) - FIND("-", A2) - 1) // segment between the 1st and 2nd hyphen

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(A2, FIND(" ", A2) + 1, FIND(" ", A2, FIND(" ", A2) + 1) - FIND(" ", A2) - 1) // "Mary Jane Watson" becomes "Jane"

MID is also the classic way to split a string into single characters for character-level tricks (Excel 365):

=MID(A2, SEQUENCE(LEN(A2)), 1) // spills one character per row

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

📊
Download the free MID practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

How do I extract text between two characters with MID?
Use FIND twice: =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?
Yes. Unlike LEFT and RIGHT, where num_chars defaults to 1, MID demands text, start_num, and num_chars every time. Leave one out and Excel rejects the formula.
What happens when num_chars runs past the end of the string?
MID returns the characters that exist and stops — no error. That is why =MID(A2, 4, 100) is a handy idiom for "everything from position 4 on."
Why does MID return an empty result?
Either start_num points past the end of the string (returns "" silently) or num_chars is 0. Check the FIND feeding start_num — it may be locating the delimiter later than you assumed.
Why does MID give #VALUE!?
start_num below 1 or num_chars below 0 — usually arithmetic in a MID + FIND combo gone negative, or the FIND itself failing because the delimiter is missing. Wrap in IFERROR for a graceful fallback.
MID vs TEXTSPLIT - which should I use?
For delimited data in Excel 365, TEXTSPLIT wins: =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

Related functions: LEFT · RIGHT · LEN · FIND · SEARCH · TEXTSPLIT