Excel MID Function (Substring by Position) – Examples & Practice
Practice the Excel MID function online with an interactive grid, instant feedback, and clear formula help.
Instruction
From text in A3, start at character 9 and return 4 characters.
Formula Syntax
=MID(text, start_num, num_chars)
- text: The text string containing the characters you want.
- start_num: The position of the first character you want (1-based).
- num_chars: How many characters to return from the start position.
What it does
MID returns a specific number of characters from a text string, starting at the position you specify. It is essential for structured text parsing.
Excel MID Function Examples
Middle segment
=MID(A3, 9, 4)
Starts at character 9 and returns 4 characters.
Prefix of known length
=MID(A2, 1, 3)
Returns the first three characters—handy for area codes or product family codes when width is fixed.
Slice after a stable prefix
=MID(B2, 5, 6)
Skips the first four characters (for example a literal prefix like INV-) and returns the next six characters.
text-cleanup.xlsx
| A | B | |
|---|---|---|
| 1 | Raw Text | Helper |
| 2 | ACME Corporation | ACME |
| 3 | Invoice-2026-0001 | 2026 |
| 4 | VIP_CLIENT | VIP |
| 5 | John Doe | Doe |
| 6 | Product Name | Product |
| 7 | Output |
Input Formula
Need Help?
Tips
- Build parsing formulas on a sample row first.
- Prefer TRIM on the source to stabilize positions.
- Consider Power Query for many columns of messy text.
MID Function Use Cases
- Parse fixed-width segments between known positions
- Extract year/month/day parts from legacy strings
- Split composite IDs when positions are stable
- Combine with FIND for delimiter-based parsing
- Repair messy imports before analysis
Common mistakes - MID function not working
- Off-by-one start positions
- Length longer than remaining characters without checks
- Using MID on numbers without TEXT coercion when needed
- Forgetting 1-based indexing if you are used to 0-based code
- Hard-coding positions that drift across vendors
FAQ
Are MID positions 1-based?
Yes. The first character is position 1.
What if start_num is past the string length?
You may get an empty string or error depending on context.
MID vs MIDB?
MIDB counts bytes; MID counts characters.
Can MID replace characters?
Not directly; use REPLACE for substitution patterns.
How do I extract between delimiters?
Combine MID with FIND for dynamic start and length.
Comparison
| Function | Best when… |
|---|---|
| MID | You know start + length |
| LEFT/RIGHT | Edge-based slices |
| TEXTSPLIT | Modern delimiter splits |
Example
=MID("ABCDEF", 2, 3) returns BCD.
Advanced examples
MID + FIND dynamic length
Compute start with FIND, then MID to pull between delimiters—classic Excel parsing.
MID on zero-padded text codes
=MID(TEXT(C2,"00000000"), 3, 4)
Turns a numeric ID into a fixed-width string before slicing, so positions stay aligned in reports.