MID Function

Excel 2007+

Summary

The Excel MID function extracts a specific number of characters from a text string, starting at the position you specify. It's perfect for pulling substrings from larger text values like names, codes, or data fields.

Syntax

MID(text, start_num, num_chars)

Parameters

Parameter Type Required Description
text Text Yes Text string or cell reference containing the characters to extract
start_num Number Yes Position to start extraction (1 for first character, 2 for second, etc.)
num_chars Number Yes Number of characters to extract from start position

Using the MID Function

MID is a fundamental text function for parsing and manipulating strings. Use it to extract specific portions of data from concatenated text, separate names into first/last components, or clean up imported data by pulling only the relevant segments.

Common MID Examples

Extract Last Name

=MID(A2,FIND(" ",A2)+1,20)

Extracts last name from full name in A2 (e.g., "John Smith" → "Smith")

Get Product Code

=MID(B2,1,5)

Pulls first 5 characters from product code (e.g., "ABC123XYZ" → "ABC12")

Extract Domain

=MID(C2,FIND("@",C2)+1,LEN(C2))

Gets domain from email address (e.g., "[email protected]" → "domain.com")

Frequently Asked Questions

MID returns an empty string "" if start_num is beyond the text length.

Yes, MID includes the character at the start_num position.

MID returns all remaining characters if num_chars exceeds available length.

Common Errors and Solutions

#VALUE! error

Cause: start_num or num_chars is not a valid number

Solution: Ensure numeric arguments are numbers or use VALUE function

Empty result ""

Cause: start_num > length of text

Solution: Use LEN function to check text length first

Notes

  • Positions are 1-based (1 = first character)
  • Maximum num_chars limited by available text length
  • Use FIND or SEARCH with MID for dynamic positioning
  • In Excel for web and Mac, behavior identical to Windows version

Compatibility

Available in: Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Microsoft 365

Not available in:

Content last reviewed: December 9, 2025
Update frequency: As needed
Excel versions tested: Excel 2007+