π§ Introduction: The Hidden Structure in Your Data
Ever looked at something like this?
INV-2025-001
SKU-UK-999
EMP-007-JS
Those strings look random β but theyβre actually structured data.
Each part has meaning: type, year, region, ID.
With Excelβs LEFT(), MID(), and RIGHT() functions, you can slice out any piece automatically β no text-to-columns, no Power Query, no VBA.
π‘ The Three Text Extraction Functions
| Function | What It Does | Example |
|---|---|---|
LEFT(text, num_chars) | Extracts text from the start | =LEFT(A2,3) β INV |
MID(text, start_num, num_chars) | Extracts text from anywhere | =MID(A2,5,4) β 2025 |
RIGHT(text, num_chars) | Extracts text from the end | =RIGHT(A2,3) β 001 |
They work like scissors β cutting your text exactly where you tell Excel to.
πΉ Example 1: Extracting Parts of an Invoice Code
Letβs start with this example:
| A (Raw Code) | Formula | Result |
|---|---|---|
| INV-2025-001 | =LEFT(A2,3) | INV |
| INV-2025-001 | =MID(A2,5,4) | 2025 |
| INV-2025-001 | =RIGHT(A2,3) | 001 |
Breakdown:
- LEFT(A2,3) β first 3 characters (
INV). - MID(A2,5,4) β start at character 5, extract 4 characters (
2025). - RIGHT(A2,3) β last 3 characters (
001).
β Result: Split cleanly into code, year, and number.
πΉ Step-by-Step Logic of MID()
=MID(A2,5,4)
| Argument | What It Means | In This Case |
|---|---|---|
text | Cell to look in | A2 |
start_num | Character to start from | 5 (skips βINV-β) |
num_chars | Number of characters to extract | 4 (the digits β2025β) |
You could even make this dynamic with FIND():
=MID(A2,FIND("-",A2)+1,4)
Now Excel finds the dash instead of assuming β5β β works for varying code lengths.
πΉ Example 2: Extract Region Codes Dynamically
| A (SKU) | Formula | Result |
|---|---|---|
| SKU-UK-999 | =MID(A2,FIND("-",A2)+1,2) | UK |
Explanation:
- FIND(“-“,A2) β position of first dash (4)
- Add 1 β start at character 5
- Extract 2 characters β βUKβ
β Output: UK
πΉ Example 3: Extract Last Digits from Employee Codes
| Code | Formula | Result |
|---|---|---|
| EMP-007-JS | =RIGHT(A2,2) | JS |
Simple and powerful β RIGHT cuts from the end, no matter how long the text.
β‘ Dynamic Extraction Using FIND + LEN
When your codes vary in length, hardcoding (like =MID(A2,5,4)) can break.
Use FIND() and LEN() to make it flexible:
=MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1)
This monster formula finds both dashes and extracts whatever is between them β whether itβs 2 letters or 5 digits.
β
Perfect for mixed data like INV-2025-001 or SKU-USA-98765.
π§ Pro Analyst Trick β Combine with VALUE()
If you extract numbers (like 2025) and plan to calculate with them:
=VALUE(MID(A2,5,4))
That converts the text β2025β into a real number you can use in formulas or charts.
βοΈ Common Mistakes
| Problem | Cause | Fix |
|---|---|---|
| Wrong characters extracted | Miscounted start/length | Use FIND() to locate exact position |
| Formula errors (#VALUE!) | Dash or symbol not present | Wrap in IFERROR() |
| Numbers not calculating | Still text | Wrap with VALUE() |
| Mixed-length codes | Hardcoded start/length | Use FIND + LEN combo |
π Copy-Paste Excel Demo Table
| A (Raw Data) | Task | Formula | Expected Result |
|---|---|---|---|
| INV-2025-001 | Extract Prefix | =LEFT(A2,3) | INV |
| INV-2025-001 | Extract Year | =MID(A2,5,4) | 2025 |
| INV-2025-001 | Extract Suffix | =RIGHT(A2,3) | 001 |
| SKU-UK-999 | Extract Region | =MID(A3,FIND("-",A3)+1,2) | UK |
| EMP-007-JS | Extract Last Letters | =RIGHT(A4,2) | JS |
β€οΈ Support XL4MULA β Free Learning, Powered by You
At XL4MULA, every video, sheet, and post is made to save you time β and teach Excel in plain English.
If this guide helped you, consider supporting future content with a voluntary donation. It keeps the tutorials free for everyone whoβs learning.
π Visit XL4MULA.com to:
- Watch the 60-second LEFT/MID/RIGHT video π₯
- Download the sample Excel sheet
- Explore all 20 Excel Cleaning Shorts
- And, if youβd like, leave a small donation β€οΈ
β Takeaway
| Function | Think of It As | Use It For |
|---|---|---|
| LEFT | From the start | Prefixes, codes, names |
| MID | From the middle | Years, IDs, categories |
| RIGHT | From the end | Suffixes, region codes |
Together, theyβre Excelβs text extraction trio β clean, fast, and perfect for automating structured data cleanup.