Formula Guide

The Excel MID Function
explained simply

MID extracts characters from any position in a text string. You control where to start and how many characters to take.

ExcelPro · 6 min read · Updated June 2026
Contents
  1. What does MID do?
  2. Syntax
  3. 5 real examples
  4. MID with FIND for dynamic extraction
  5. FAQ

What does MID do?

MID extracts a specific number of characters from any position in a text string. Unlike LEFT (which always starts from the beginning) and RIGHT (which always starts from the end), MID lets you start anywhere. Use it to extract codes embedded in the middle of longer strings.

Syntax

=MID(text, start_num, num_chars)
ArgumentDescription
text requiredThe string to extract from.
start_num requiredThe position of the first character to extract. 1 = first character.
num_chars requiredHow many characters to extract from that starting position.

5 real examples

Example 1
Extract middle section of a code
=MID(A2, 4, 3) ← "GB-LON-2026" → "LON"

Start at position 4 (after "GB-"), extract 3 characters.

Example 2
Extract NI number middle section
=MID(A2, 3, 6) ← "AB123456C" → "123456"
Example 3
Extract month from date code
=MID(A2, 5, 2) ← "2026-06-14" → "06"
Example 4
Extract domain from email
=MID(A2, FIND("@",A2)+1, LEN(A2)-FIND("@",A2))

Find the @ sign, then extract everything after it.

Example 5
Extract text between two characters
=MID(A2, FIND("(",A2)+1, FIND(")",A2)-FIND("(",A2)-1)

Extracts text between parentheses: "Revenue (GBP)" → "GBP".

MID with FIND for dynamic positions

When the start position varies, use FIND to locate a separator, then offset from it.

Extract between first and second hyphen: =MID(A2, FIND("-",A2)+1, FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1) "GB-LON-2026" → "LON"

FAQ

What happens if start_num is beyond the string length?
MID returns an empty string "" without an error.
What if num_chars extends beyond the end of the string?
MID returns characters up to the end of the string without error.
Is MID case sensitive?
No — MID extracts characters as-is. Wrap with UPPER or LOWER to standardise the result.

MID in data cleaning and code parsing

MID is most powerful when your data contains structured codes where a meaningful piece of information sits at a fixed position. National Insurance numbers (AB123456C) have the numeric section starting at position 3. UK company registration numbers have type codes at specific positions. Product codes often encode category, year, and sequence at known positions.

The challenge comes when positions are variable — the middle section of "GB-LON-2026" starts at position 4, but "GBP-LONDON-2026" has it at position 5. This is where FIND becomes essential: MID(A2, FIND("-",A2)+1, FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1) extracts between the first and second hyphen regardless of what comes before.

MID also works with numbers — MID(TEXT(A2,"00000000"),3,4) extracts digits 3-6 from a padded number. This technique is used in financial systems where account numbers or sort codes need to be parsed from longer strings.

Practise MID, LEFT and RIGHT together

ExcelPro has text extraction exercises in every track. Real string manipulation scenarios, free to start.

Try text exercises →

Related formulas

LEFT RIGHT FIND LEN SUBSTITUTE TRIM