MID

The MID function is used to extract a specific number of characters from a text string, starting at a specified position. It is handy for manipulating text data in Excel and extracting substrings from strings.

Syntax

=MID(Text, Start_num, Num_chars)

Text The text string from which you want to extract characters.
Start_num The starting position from which extraction should begin.
Num_chars The number of characters to extract from the text string.

About MID

When you find yourself in need of pinpointing specific sections of text within a larger string, that's where the MID function in Excel comes to play. This function acts as your go-to tool for diving into text manipulation and extracting precise substrings based on defined positions and lengths within the source text. This feature is particularly valuable in scenarios where you need to isolate or manipulate specific data segments within a text field, such as extracting part numbers, account codes, or names from a text block. By supplying the original text string, the starting position for extraction, and the desired length of the substring, you can precisely capture the information you require for further analysis or processing.

Examples

Suppose you have the text string 'ExcelRocks2022' and you want to extract 'Rocks'. You can use the MID formula as follows: =MID('ExcelRocks2022', 6, 5)

If you have the text string 'DataAnalysis101', and you wish to extract 'Analysis', you would employ the MID function in this manner: =MID('DataAnalysis101', 5, 8)

Questions

Can the MID function be used to extract characters from numeric values?

No, the MID function is primarily designed for manipulating text data and extracting substrings. It may not provide the desired results when used with numeric values.

Is it possible to nest the MID function within other functions in Excel?

Yes, you can nest the MID function within other Excel functions to perform more complex text manipulation or analysis tasks. Combining MID with functions like IF, FIND, or CONCATENATE can enhance its capabilities.

What happens if the specified number of characters to extract exceeds the length of the text string?

If the number of characters specified for extraction extends beyond the length of the text string starting from the given position, the MID function will extract all available characters up to the end of the text string. It will not return an error, but the extracted substring length will be adjusted accordingly.

Related functions

LEFT
RIGHT
FIND
SEARCH
SUBSTITUTE