
π This article includes 2 downloadable practice files β
In this article
MID returns characters from the middle of a text, starting at a position you choose.
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
| Text | Formula | Result |
|---|---|---|
| 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
| Mistake | What to do instead |
|---|---|
| Off-by-one start position | Count characters starting from 1 |
| Variable positions | Use FIND/SEARCH to calculate the start |
Related functions
LEFT Β· RIGHT Β· FIND Β· SEARCH
π Part of the free Excel course: Beginner β Expert Β· Try it in the Formula Lab or ask the AI Helper.
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.
Atul (AJ) builds office-automation and local-first AI tools as Atulya AI, and works with Excel, SAP and Oracle EPM every day. He writes about the shortcuts, macros and automations that actually save time β plus the occasional wacky fact. Videos on YouTube: Lazy Automator AI (@LazyAutomatorAI).
More posts by Atul βBuild this skill next
This page is a quick function reference. Use it for syntax, then practise the function in a broader workflow.
Stuck on a step? Ask a question and the AI answers using this article.