Text · extract from the middle · Nov 2026

The MID function,
measured & explained.

Syntax, a live playground, a measured position gallery, the 1-based-start trap, and a sourced error library: extracting text from the middle.

D1
fx
=MID(A2, 2, 3)
0
measured gallery rows
0
sourced errors fixed
0
platforms checked
// 01 — Anatomy

How MID works

Returns num_chars characters starting at start_num. A start below 1 is #VALUE!; a start past the end returns empty.

=MID(text, start_num, num_chars)
textThe string to extract from.
start_numThe 1-based position to start at; must be ≥ 1.
num_charsHow many characters to take; over-length takes the rest.
.bool-moat td.res-text{color:var(--cyan);font-weight:700;font-family:var(--mono)}
// 02 — Extract from the middle

What MID actually returns

MID returns num_chars characters starting at a 1-based position. It generalises LEFT and RIGHT — but the start position has its own rules. Every row was measured live in HyperFormula. Click any row to load it.

Position gallery — start_num is 1-based

ExpressionResultWhy
=MID(A2,2,3)xceStart at 2, take 3
=MID(A2,1,3)ExcStart 1 is the same as LEFT
=MID(A3,3,4)rmulFormula from position 3
=MID(A4,2,2)ooLookup middle
=MID(A2,2,10)xcelOver-length takes the rest
=MID("Hello",2,3)ellWorks on a literal
=MID(A2,2,2.9)xcDecimal num_chars truncated to 2
=MID(A2,6,1)""Start past the end: empty string

Edge cases

ExpressionResultWhy
=MID(A2,0,3)#VALUE!Start below 1 is an error
=MID(A2,2,-1)#VALUE!Negative num_chars is an error
⚠ start_num must be at least 1. A start of 0 or negative is #VALUE!, and a negative num_chars is #VALUE!. A start beyond the text length returns an empty string, not an error. Over-length num_chars simply takes whatever remains.
// 03 — Try it live

Interactive MID playground

Edit the table or type any formula — the engine evaluates instantly. Load a preset to see MID slice from the middle, match LEFT at start 1, and take the rest when over-length.

A1Sample data — click any cell to edit, the formula re-evaluates live
Result
—
✓ readyHyperFormula 3.5
// 04 — Error library

The real-world error library

8 failure patterns mined from actual user reports on Reddit, Stack Overflow and Super User — each with the authentic symptom, root cause, a fix, and a runnable formula. Not textbook theory.

// 05 — Cross-platform

Where MID works

MID is available across modern Excel, Google Sheets and LibreOffice. It has been in Excel since 2003.

PlatformSupportNotesGotcha
✓ Supported full MID◐ Partial works with caveatsCompiled from public docs · verify against your build
// Go deeper

Master text extraction

MID is one piece. The full course walks the toolkit end to end with live, measured examples.

  • LEFT / RIGHT / MID — choosing the extraction direction
  • The 1-based start and its traps
  • Over-length and past-the-end behaviour
  • TEXT + MID for numbers and dates
Free while in beta
Browse the function library

No account needed. Every page has a live playground.

// 07 — FAQ

Frequently asked