ID EN
#Text

MID

Excel Functions

Extract text from inside a string

Syntax

EXCEL
=MID(text, start_num, num_chars)

Arguments

Parameter Description
text The text to extract from.
start_num The location of the first character to extract.
num_chars The number of characters to extract.

Return Value

The characters extracted.

Details

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. To extract text with MID, just provide the text, the starting position, and the number of characters to extract. The formulas below show how to extract one, two, and three characters with MID: The formula below returns 3 characters starting at the 5th character: This formula will extract 3 characters starting at character 16: If

Examples

MID function basics

To extract text with MID, just provide the text, the starting position, and the number of characters to extract. The formulas below show how to extrac

EXCEL
=MID("apple",1,1) // returns "a"
=MID("apple",1,2) // returns "ap"
=MID("apple",1,3) // returns "app"
MID function basics

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

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

This formula will extract 3 characters starting at character 16:

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

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

EXCEL
=MID("apple",1,100) // returns "apple"
MID function basics

This can be useful as a way to simply certain formulas as explained below. MID can extract text from numbers, but the result is text:

EXCEL
=MID(12348,3,4) // returns "348" as text
Example 1 - extract date from serial number

In the example below, we use the MID function to extract a date in YYYYMM notation from a serial number with 14 characters. The formula in cell D5, co

EXCEL
=MID(B5,5,6)

See Also

LEFT RIGHT MID LEN TEXTBEFORE TEXTAFTER TEXTSPLIT