MID Function
Master the MID function to extract text from any position. Learn syntax, examples, and solutions to common errors for precise text manipulation.




=MID(text, start_num, num_chars)
Practical Examples
Extract Product Year from SKU
Parse the year from a product SKU code
Extract Area Code from Phone Number
Parse area code from formatted phone numbers
Parse Middle Name Initial
Extract middle initial from full names
Extract Order ID from Transaction String
Parse order ID from complex transaction codes
Extract Department Code with Error Handling
Safely extract department codes with IFERROR
Common Errors and Solutions
MID returns #VALUE! error
Start_num or num_chars is negative, or start_num is not a number
1. Verify start_num is a positive number (use ABS() if needed) 2. Check that num_chars is positive 3. Ensure cell references contain numeric values 4. Use VALUE() to convert text numbers to actual numbers
Always validate position and length parameters before using them in MID
Example:
MID returns blank/empty result
Start_num is greater than the text length or num_chars is 0
1. Check text length with LEN() function 2. Verify start_num doesn't exceed text length 3. Ensure num_chars is greater than 0 4. Use IF(LEN(A1)>=start_num, MID(...), "N/A")
Implement length checking before extraction
Example:
MID extracts incorrect portion of text
Incorrect starting position due to miscounting or hidden characters
1. Use TRIM() to remove extra spaces 2. Use CLEAN() to remove non-printable characters 3. Count positions carefully, remembering position 1 is the first character 4. Use SUBSTITUTE() to standardize delimiters before extraction
Clean and standardize data before applying MID
Example:
Extracted numbers won't calculate
MID always returns text format, even for numeric characters
1. Wrap MID with VALUE() function: VALUE(MID(...)) 2. Multiply result by 1: MID(...)*1 3. Add 0 to result: MID(...)+0 4. Use TEXT() function if specific number format needed
Plan for type conversion when extracting numeric data
Example:
Best Practices and Advanced Tips
Combine MID with FIND or SEARCH functions to extract text between delimiters dynamically. This adapts to varying text lengths and positions.
In Excel 365 and Google Sheets, MID works with dynamic arrays. Apply it to entire columns for bulk extraction without copying formulas.
Beware of hidden characters like non-breaking spaces (CHAR(160)) that can throw off position counting. Use CLEAN() and TRIM() functions to standardize text first.
Always validate text length before extraction to avoid errors. Combine with IF and LEN for robust formulas in production spreadsheets.
For large datasets (>10,000 rows), pre-calculate positions in helper columns rather than using nested FIND functions repeatedly. This can improve recalculation speed by 60%.
Need Help with MID Function?
Stop struggling with formula syntax. Use AskFormulas to generate validated formulas instantly with our AI-powered tool.
Example Excel formula:
Related Formulas
Extract text from the beginning of strings with the LEFT function. Learn syntax, examples, and error solutions for Excel and Google Sheets.

Master CONCATENATE to join text in Excel and Google Sheets. Learn syntax, examples, errors, and modern alternatives like CONCAT and TEXTJOIN.
