How to Use MID Function in Excel: Extract Text Easily
The
MID function in Excel extracts a specific number of characters from the middle of a text string, starting at any position you choose. Use =MID(text, start_num, num_chars) where text is the original string, start_num is where to begin, and num_chars is how many characters to take.Syntax
The MID function has three parts:
- text: The text string you want to extract from.
- start_num: The position in the text where you want to start extracting. The first character is 1.
- num_chars: The number of characters you want to extract from the start position.
excel
=MID(text, start_num, num_chars)
Example
This example extracts 5 characters from the word "Welcome" starting at the 2nd character.
excel
=MID("Welcome", 2, 5)
Output
elcom
Common Pitfalls
Common mistakes include:
- Starting position (
start_num) less than 1 or greater than the text length, which returns an empty string. - Requesting more characters (
num_chars) than remain in the text, which just returns characters up to the end. - Using non-text values without converting them to text first.
excel
=MID("Hello", 0, 3) <strong>Wrong:</strong> start_num cannot be 0 =MID("Hello", 2, 10) <strong>Right:</strong> returns "ello" even if 10 is too large
Quick Reference
| Parameter | Description | Example |
|---|---|---|
| text | The text to extract from | "Excel" |
| start_num | Position to start extraction (1 = first character) | 2 |
| num_chars | Number of characters to extract | 3 |
Key Takeaways
Use MID to extract characters from any position inside a text string.
Start counting characters at 1, not 0.
If you ask for more characters than available, MID returns up to the end of the text.
Avoid start positions less than 1 to prevent errors.
MID works with text; convert numbers to text if needed.