
Extracts a chosen number of characters from any position inside a text string.
The Excel MID function returns a specified number of characters from the middle of a text string. You choose where to start and how many characters to take. For example, =MID("ABC-123-XYZ",5,3) returns "123".
MID is the most flexible of the three basic extraction functions. LEFT starts from the beginning, RIGHT starts from the end, and MID can start anywhere you specify.
MID is one of the most flexible extraction functions because it handles the section in between the start and end of a string. LEFT is good for prefixes and RIGHT is good for endings, but MID is the one that becomes useful when another formula first calculates the correct starting position and length.
Returns a part of a text string based on a start position and a length.
Returns the extracted characters as text.
=MID(text, start_num, num_chars)
MID needs three arguments. text is the source value. start_num tells Excel where to begin. num_chars tells Excel how many characters to return from that position.
Use the extraction function that matches where your target text sits in the string. MID is the best choice when the text is in the middle or when the start position has to be calculated.
| Function | Starts From | Use When |
|---|---|---|
LEFT |
The first character | The needed text is at the beginning |
MID |
A position you choose | The needed text is in the middle |
RIGHT |
The last character | The needed text is at the end |
FIND / SEARCH |
- | You first need to locate a delimiter |
MID works well when the segment you need always begins at the same position. If a code always stores the year in characters 5 to 8, MID can extract it directly with fixed numbers.
When the position changes from row to row, MID is often paired with FIND. FIND locates a delimiter such as a hyphen, and MID starts right after that delimiter. This makes the formula adapt to different prefix lengths.
When the target segment always sits in the same place, MID is straightforward. You just give the start position and the number of characters to return.
=MID("ABC-123-XYZ", 5, 3) // "123"
=MID("ENG-2025-Q1", 5, 4) // "2025"
In cell B2, use MID to extract the middle segment from the first source row.
If the phone number format is consistent, the area code is always in the same place. In (555) 000-1111, the three digits begin at position 2, so MID can return them directly.
=MID("(555) 000-1111", 2, 3) // "555"
In cell B3, use MID on the phone number row to extract the area code.
MID can sit inside a comparison or an IF formula when a certain segment of the string has meaning. That is useful for testing batch codes, department codes, or other structured parts of an identifier.
=MID(A4, 4, 3)="789"
=IF(MID(A4, 4, 3)="789", "Priority", "Standard")
In cell B4, check whether the middle segment of the code row matches the expected value.
When the prefix length changes, a fixed start position will break. Using FIND lets MID calculate the correct starting point from the actual text, so the formula still works when the prefix gets longer or shorter.
=MID(A4, FIND("-",A4)+1, 3)
// "ID-789-X" -> "789"
In cell C4, combine MID and FIND to extract the code after the first hyphen.
MID works with text, numbers, and dates, but it always extracts from the stored text form of the value. If you need to extract from a displayed format, convert the value with TEXT first.
MID is the extraction function to use when the text you need is not at the start or the end. This lesson showed that it works well for pulling codes, area segments, and other pieces from the middle of a longer value.
The biggest improvement comes when you combine MID with FIND. That turns it from a fixed-position tool into a more flexible one, because the formula can first locate a delimiter and then extract the exact section after it.
MID returns characters from any position in a text string.=MID(text, start_num, num_chars).Tell your friends about this post