Need to extract characters from the middle of text? MID returns a specific number of characters starting from any position you choose. It’s the most flexible text extraction function for pulling data from anywhere within a string.
What Makes MID Useful
MID extracts text from any position:
- Precise extraction – Get characters from any starting point
- Middle data – Extract information buried between other text
- Fixed-position parsing – Pull data from specific character positions
- Flexible length – Control exactly how many characters to extract
- Code parsing – Extract segments from structured codes or IDs
The Syntax
=MID(text, start_num, num_chars)Text is your source string. Start_num is where to begin (1 = first character). Num_chars is how many characters to extract.
Example 1: Extract Month from Date String
Get the month from YYYY-MM-DD format:
| Date String |
|---|
| 2025-03-15 |
| 2024-11-28 |
| 2025-07-04 |
Formula: =MID(A2, 6, 2)
Result in B2: 03
Starts at position 6, extracts 2 characters (the month).
Example 2: Extract Middle Initial
Get middle names or initials:
| Full Name |
|---|
| John M. Smith |
| Sarah A. Johnson |
| Mike R. Williams |
Formula: =MID(A2, 6, 2)
Result in B2: M.
Starts at position 6, extracts 2 characters (initial and period).
Example 3: Extract Product Code Segment
Get the middle part of structured codes:
| Product Code |
|---|
| ABC-2025-XYZ |
| DEF-2024-MNO |
| GHI-2025-PQR |
Formula: =MID(A2, 5, 4)
Result in B2: 2025
Starts at position 5 (after ABC-), extracts 4 characters (the year).
Example 4: Dynamic Starting Position
Extract text starting from a delimiter:
| john@company.com |
| sarah@business.org |
| mike@email.net |
Formula: =MID(A2, SEARCH("@", A2)+1, SEARCH(".", A2)-SEARCH("@", A2)-1)
Result in B2: company
Starts after @, extracts until the period.
Example 5: Extract Substring Between Characters
Get text between two delimiters:
| Data |
|---|
| [Category] Product Name |
| [Type] Item Description |
| [Code] Reference Number |
Formula: =MID(A2, 2, SEARCH("]", A2)-2)
Result in B2: Category
Starts at position 2 (after [), extracts until ] is found.
Example 6: Extract Area Code from Formatted Phone
Get area code from (555) 123-4567 format:
| Phone Number |
|---|
| (555) 123-4567 |
| (415) 987-6543 |
| (212) 456-7890 |
Formula: =MID(A2, 2, 3)
Result in B2: 555
Starts at position 2 (after opening parenthesis), extracts 3 digits.
MID vs LEFT vs RIGHT
| Function | Extracts From | Example |
|---|---|---|
| MID | Any position | MID(“Hello”, 2, 3) = “ell” |
| LEFT | Start of text | LEFT(“Hello”, 2) = “He” |
| RIGHT | End of text | RIGHT(“Hello”, 2) = “lo” |
Common Use Cases
Structured Data Parsing Extract segments from fixed-format codes or IDs.
Date Component Extraction Pull day, month, or year from date strings.
Text Between Delimiters Get content between brackets, quotes, or other markers.
Social Security Numbers Extract middle segment: MID(A2, 5, 2) from 123-45-6789.
Practical Combinations
Extract between two characters:
=MID(A2, SEARCH("(", A2)+1, SEARCH(")", A2)-SEARCH("(", A2)-1)Extract word at position N:
=MID(A2, SEARCH("~", SUBSTITUTE(A2, " ", "~", N))+1, SEARCH("~", SUBSTITUTE(A2, " ", "~", N+1)&"~")-SEARCH("~", SUBSTITUTE(A2, " ", "~", N))-1)Extract after Nth occurrence:
=MID(A2, SEARCH("~", SUBSTITUTE(A2, "-", "~", 2))+1, 100)Extract fixed segment:
=MID(A2, 10, 5)Always positions 10-14.
Dynamic Extraction
Variable starting position:
=MID(A2, SEARCH("@", A2)+1, 10)Variable length:
=MID(A2, 5, SEARCH("-", A2)-5)Both dynamic:
=MID(A2, SEARCH("[", A2)+1, SEARCH("]", A2)-SEARCH("[", A2)-1)Common Mistakes to Avoid
Starting Position = 0
- Position counting starts at 1, not 0
- First character is position 1
- MID(A2, 0, 5) causes an error
Num_Chars Too Large
- MID extracts to end of string if num_chars is too big
- Doesn’t cause an error
- MID(“Hello”, 2, 100) = “ello”
Forgetting to Add 1
- After SEARCH/FIND, add 1 to start after delimiter
- SEARCH finds delimiter position
- Add 1 to skip the delimiter itself
Error Handling
Check if delimiters exist:
=IF(ISNUMBER(SEARCH("[", A2)), MID(A2, SEARCH("[", A2)+1, SEARCH("]", A2)-SEARCH("[", A2)-1), "")Handle missing data:
=IFERROR(MID(A2, SEARCH("@", A2)+1, 10), A2)Validate position:
=IF(LEN(A2)>=10, MID(A2, 5, 5), "Too short")Working with Numbers
Convert extracted text to number:
=VALUE(MID(A2, 5, 4))Extract and calculate:
=VALUE(MID(A2, 10, 3)) * 1.1Date conversion:
=DATE(MID(A2, 1, 4), MID(A2, 6, 2), MID(A2, 9, 2))Converts “2025-03-15” to actual date.
Advanced Patterns
Extract all words individually:
Word 1: =LEFT(A2, SEARCH(" ", A2)-1)
Word 2: =MID(A2, SEARCH(" ", A2)+1, SEARCH(" ", A2, SEARCH(" ", A2)+1)-SEARCH(" ", A2)-1)Extract Nth character:
=MID(A2, N, 1)Where N is the position.
Extract between quotes:
=MID(A2, SEARCH(CHAR(34), A2)+1, SEARCH(CHAR(34), A2, SEARCH(CHAR(34), A2)+1)-SEARCH(CHAR(34), A2)-1)CHAR(34) is the quote character.
Data Parsing Examples
Parse credit card (show middle):
=MID(A2, 6, 4)From 1234-5678-9012-3456.
Extract username from email:
=MID(A2, 1, SEARCH("@", A2)-1)Actually better done with LEFT.
Get middle digits:
=MID(A2, 4, 3)From 7-digit phone: 555-1234.
Tips for Using MID
Combine with LEN for last segment:
=MID(A2, start_position, LEN(A2)-start_position+1)Use with SUBSTITUTE for Nth occurrence:
=MID(A2, SEARCH("~", SUBSTITUTE(A2, "-", "~", 2))+1, 5)Chain with TRIM:
=TRIM(MID(A2, 5, 10))Removes extra spaces from extracted text.
When to Use MID
Use MID when:
- Extracting from the middle of text
- You know the exact starting position
- Need both start position and length control
- Parsing fixed-format data
Don’t use MID when:
- Need text from the start (use LEFT)
- Need text from the end (use RIGHT)
- Start position is 1 (use LEFT instead)
Start Using It
Open a spreadsheet with structured text data. Identify which characters you need. Count the starting position and how many characters to extract. Type =MID with those values.
MID becomes essential for parsing structured codes and extracting middle segments.
Questions about MID? Ready to combine LEFT, RIGHT, and MID for complex text parsing? Let’s connect.

