Quick Navigation
MID & MIDB Functions
Summary
The MID function extracts a specific number of characters from any position within a text string. MIDB serves the same purpose but counts each double-byte character as two single-byte characters, making it suitable for certain double-byte language systems. MIDB is now deprecated in modern Excel.
Syntax
MID(text, start_num, num_chars)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | Text |
Yes | Source text string containing characters to extract |
| start_num | Number |
Yes | Starting character position (1-based index) |
| num_chars | Number |
Yes | Number of characters to return from start position |
Using the MID, MIDB Function
MID is perfect for parsing structured text data, extracting codes, names, or specific segments from concatenated strings. Use dynamic start positions with SEARCH/FIND functions for flexible parsing. MIDB was used for double-byte character sets but is deprecated.
Common MID, MIDB Examples
Basic Text Extraction
=MID(A2,1,5)
Extracts first 5 characters from cell A2 (e.g., "Fluid" from "Fluid Flow")
Extract from Middle
=MID(A2,7,20)
Returns characters starting at position 7, up to available length ("Flow")
Dynamic Position with SEARCH
=MID(A2,SEARCH(" ",A2)+1,5)
Extracts 5 characters after first space
Handle Long Extraction
=MID("Product-ABC123",9,10)
Returns "ABC123" (stops at end of string)
Frequently Asked Questions
Common Errors and Solutions
#VALUE! error
Cause: start_num < 1 or num_chars < 0
Solution: Ensure start_num ≥ 1 and num_chars ≥ 0
Unexpected short result
Cause: start_num too large
Solution: Verify start_num doesn't exceed text length
Wrong substring
Cause: Off-by-one positioning
Solution: Remember positions start at 1, not 0
Notes
- Position 1 = first character
- If extraction exceeds text end, returns remaining characters
- Empty result "" when start_num > text length
- MIDB deprecated - use MID for all modern workbooks
- Improved Unicode handling in Compatibility Version 2
Compatibility
Available in: Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Microsoft 365
Not available in:
Content last reviewed: December 10, 2025
Update frequency: As needed
Excel versions tested: Excel 2007+