Summary

The Excel MID function extracts a given number of characters from the middle of a supplied text string. For example, =MID("apple",2,3) returns "ppl".

Purpose 

Extract text from inside a string

Return value 

The characters extracted.

Syntax

=MID(text,start_num,num_chars)
  • text - The text to extract from.
  • start_num - The location of the first character to extract.
  • num_chars - The number of characters to extract.

How to use 

The MID function extracts a given number of characters from the middle of a supplied text string. MID takes three arguments, all of which are required. The first argument, text, is the text string to start with. The second argument, start_num, is the position of the first character to extract. The third argument, num_chars, is the number of characters to extract. If num_chars is greater than the number of characters available, MID returns all remaining characters.

Examples

The formula below returns 3 characters starting at the 5th character:

=MID("The cat in the hat",5,3) // returns "cat"

This formula will extract 3 characters starting at character 16:

=MID("The cat in the hat",16,3) // returns "hat"

If num_chars is greater than remaining characters, MID will all remaining characters:

=MID("apple",3,100) // returns "ple"

MID can extract text from numbers, but the result is text:

=MID(12348,3,4) // returns "348" as text

Related functions

Use the MID function to extract from the middle of text. Use the LEFT function to extract text from the left side of a text string and the RIGHT function to extract text starting from the right side of text. The LEN function returns the length of text as a count of characters. Use FIND or SEARCH to locate an unknown start position.

Notes

  • num_chars is optional and defaults to 1.
  • MID will extract text from numeric values, but the result is text
  • Number formatting is not counted or extracted.
Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.