MID Function

MID Function

MID Function

Extracts a chosen number of characters from any position inside a text string.

ExcelClash Team
PUBLISHED

Summary

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.

Purpose

Extract text from any position

Returns a part of a text string based on a start position and a length.

Return Value

A text string

Returns the extracted characters as text.

Syntax

=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.

Arguments

  • text - [Required] The text string or cell reference to extract from.
  • start_num - [Required] The position of the first character to return. Position 1 is the first character.
  • num_chars - [Required] The number of characters to return.

MID vs Other Functions

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

Using MID

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.

  • Use MID with fixed numbers when the text pattern is consistent.
  • Use MID with FIND when the starting position depends on a separator.
  • Remember that MID returns text, even if the extracted part looks numeric.

Example 1 - Extracting a Fixed Middle Segment

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"
Check Answer
Challenge #1
Target: Sheet1!F1
Extract the Middle Segment

In cell F1, use MID to extract "123" from A2 ("ABC-123-XYZ"). The numbers start at position 5 and are 3 characters long.

Example 2 - Pulling the Area Code from a Phone Number

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"
Check Answer
Challenge #2
Target: Sheet1!F2
Pull the Area Code from a Phone Number

In cell F2, use MID on A3 ("(555) 000-1111") to extract just the 3-digit area code, starting at position 2.

Example 3 - Checking if a Middle Segment Matches

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")
Check Answer
Challenge #3
Target: Sheet1!F3
Check a Specific Segment

In cell F3, check if the segment starting at position 4 of A4 is exactly "789". Formula: =MID(A4,4,3)="789".

Example 4 - Dynamic Extraction Using FIND

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"
Check Answer
Challenge #4
Target: Sheet1!F4
Dynamic Extraction Using FIND

In cell F4, combine MID and FIND to extract the 3 characters after the first hyphen in A4, regardless of prefix length.

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.

  • All three MID arguments are required.
  • Use FIND with MID when the cut point depends on a delimiter.
  • If the extracted value should behave like a number, you may need to convert it afterward.

Conclusion Recap

  • Summary: MID returns characters from any position in a text string.
  • Syntax: =MID(text, start_num, num_chars).
  • Key point: MID is best when the text you need is in the middle.
  • Practical usage: Codes, year segments, area codes, and text between separators.
  • Best pattern: Combine MID with FIND when the starting position is not fixed.
Tactical Arena
Select Scenario:
Share MID Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.