MID Function in Excel: Extract Text From the Middle

MID Function in Excel: Extract Text From the Middle featured illustration

πŸ“Ž This article includes 2 downloadable practice files ↓

⏱ 2 min readUpdated 5 October 2026

TextLevel: BeginnerAvailable in: Excel 2007+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. Example 2
  5. MID in practice
  6. Where you will use it
  7. Worked example
  8. Mistakes people make
  9. Related functions
  10. Continue learning

MID returns characters from the middle of a text, starting at a position you choose.

Advertisement

Syntax

=MID(text, start_num, num_chars)
Argument What it means
text The text.
start_num Position of the first character (1 = first).
num_chars How many characters to take.

Examples

Example 1

=MID(A2, 3, 10)

PAN from a 15-character GSTIN.

Example 2

=MID(A2, 4, 2)

Month from a code like INV0525-001.

MID in practice

Where you will use it

  • Year inside an invoice number
  • PAN inside a GSTIN (characters 3-12)
  • Month from text dates like 2026-10-04

Worked example

TextFormulaResult
INV-2026-0145=MID(A2,FIND("-",A2)+1,4)2026
CN-2025-0009=MID(A3,FIND("-",A3)+1,4)2025
DN-2027-0077=MID(A4,FIND("-",A4)+1,4)2027

Results calculated in Excel.

Mistakes people make

MistakeWhat to do instead
Off-by-one start positionCount characters starting from 1
Variable positionsUse FIND/SEARCH to calculate the start

LEFT Β· RIGHT Β· FIND Β· SEARCH

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

⬇ Download all 2 files (ZIP Β· 38 KB)

  • πŸ“—
    Text-cleaning scenarios workbookExtract and clean text (GSTIN, PAN, emails, names) with PASS/FAIL checks, plus the 3 mistakes that break text formulas.
    ⬇ XLSX Β· 8 KB
  • πŸ“—
    Practice workbook: Text & cleaning24 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 35 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong