MID Function in Excel: Extract Text from Middle of Strings

Returns a specific number of characters from a text string, starting at the position you specify.

Generated Formula
=MID(A1, 3, 5)

Learning Resources

Want to master Excel? Check out this Top-Rated Course.

How to Use the MID Function in Excel

The MID function returns a specific number of characters from a text string, starting at the position you specify.

Syntax

=MID(text, start_num, num_chars)

Example

To extract the 4-digit year from ID code "PROJ-2026-US": =MID(A2, 6, 4) returns "2026".

Common Errors & Fixes

  • #VALUE! error or wrong result

    Causes:
    • start_num is less than 1.
    • num_chars is negative.
    • The text is shorter than the start position.
    Fixes:
    • Ensure start_num is at least 1.
    • Use a positive number for num_chars.
    • Check the actual length of the text string first with LEN.

Frequently Asked Questions

What happens if start_num is negative or zero?

MID returns a #VALUE! error if start_num is less than 1. Always start from position 1 or higher.

What if start_num is beyond the text length?

MID returns an empty string ("") if start_num exceeds the total length of the text.

How do I extract text between two characters?

Combine MID with FIND: =MID(A1, FIND("(", A1)+1, FIND(")", A1)-FIND("(", A1)-1) extracts text between parentheses.

Related Formulas

Explore related formula generators to solve similar problems

Want to become an Excel Pro?

Stop searching for formulas. Master Excel in 30 days with this top-rated course.

Learn More