What it does
MID needs three things: the text, the position of the first character to take and how many characters to take. Counting starts at 1, so =MID("KBL-1525-SY",5,4) starts at the fifth character, takes four and returns "1525".
If the middle part is not in the same place on every row, calculate the start with FIND: the position of the first hyphen plus one is the first character of the part. A generous num_chars (say 100) also works, because MID does not complain when it runs past the end; it just returns the characters that are left.
If the start is always 1, LEFT reads better; if the part sits at the end, use RIGHT. In Microsoft 365, TEXTBEFORE and TEXTAFTER together can also return the text between two delimiters.
Syntax
=MID(text, start_num, num_chars)=PARÇAAL(metin; başlangıç; karakter_sayısı)Arguments in square brackets are optional. English Excel separates arguments with commas (,) and uses a dot for decimals; Turkish Excel uses semicolons (;) and a decimal comma. Excel shows function names in its own language when it opens the file.
Arguments
| Argument | Required | Description |
|---|---|---|
text | Required | The text to take characters from, or a cell. |
start_num | Required | The position of the first character to take; the first character of the text is 1. If it is beyond the end of the text, the result is empty text; it cannot be less than 1. |
num_chars | Required | How many characters to take. If this runs past the end, only the remaining characters are returned. It cannot be negative. |
Examples
1Take the size from the middle of a code
Characters 5 to 8 of each cable code are the size code. The codes have the same length, so the start is 5 and the number of characters is 4.
=MID(A2,5,4)| A | B | |
|---|---|---|
| 1 | Product Code | Size |
| 2 | KBL-1525-SY | 1525 |
| 3 | KBL-1540-KR | 1540 |
| 4 | KBL-2525-SY | 2525 |
| 5 | KBL-0610-MV | 0610 |
- B2 (filled down to B5)
=MID(A2,5,4)
B2 shows 1525 and B5 shows 0610. The result is text, so the leading zero is kept.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
2Split out the city in brackets
Each customer name ends with the city in brackets. The start is one after the opening bracket; the length is the distance between the two brackets minus one.
=MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1)| A | B | |
|---|---|---|
| 1 | Customer | City |
| 2 | Brown & Sons Ltd (Leeds) | Leeds |
| 3 | Northgate Supplies (York) | York |
| 4 | Harbour Trade (Bristol) | Bristol |
| 5 | Star Market (Manchester) | Manchester |
- B2 (filled down to B5)
=MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1)
The city names have different lengths, but every row returns only the text inside the brackets: B2 shows Leeds and B3 shows York.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
3Get the year from numbers with prefixes of different lengths
The prefix of each document number has two to four letters, but the year always comes after the first hyphen. FIND calculates the start.
=MID(A2,FIND("-",A2)+1,4)| A | B | |
|---|---|---|
| 1 | Document No | Year |
| 2 | INV-2025-0042 | 2025 |
| 3 | RTN-2024-0007 | 2024 |
| 4 | PO-2025-0113 | 2025 |
| 5 | CRED-2024-0990 | 2024 |
- B2 (filled down to B5)
=MID(A2,FIND("-",A2)+1,4)
B3 shows 2024 and B4 shows 2025. A fixed =MID(A2,5,4) would cut the rows with shorter or longer prefixes in the wrong place.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
Common errors and fixes
- #VALUE!
Cause: start_num is less than 1 or num_chars is negative, or the FIND that calculates the start did not find what it was looking for.
Fix: Check that every row contains the delimiter, and wrap the formula in IFERROR if needed.
- Empty result
Cause: start_num is larger than the length of the text. Usually the position was calculated wrongly or the text is shorter than expected.
Fix: Compare the position with LEN and check that the delimiter is spelled correctly.
- Shifted part
Cause: The codes have different lengths, so a fixed start cuts some rows in the middle of the part.
Fix: Calculate the start from the delimiter instead of typing it:
=MID(A2,FIND("-",A2)+1,4).
Good to know
- The result is text. To calculate with digits taken from the middle, use
=--MID(A2,5,4). - To find the second delimiter, start the search one character after the first:
=FIND("-",A2,FIND("-",A2)+1).
In Nexell
Get Nexell to do it from a sentence
Move the city in brackets in the customer name into a separate City column
Convert to tableBring your customer list into the tool and type this. Nexell builds the City column with real Excel text formulas and shows it in the preview first; in the downloaded file, the city updates when you edit the name.
Nexell uses AI to understand the request and builds the result with real Excel formulas; the formula may differ from the example on this page. You see a preview first and nothing changes until you press Apply; formulas stay live in the downloaded .xlsx file.
Free account · no card needed · 30 credits a month
Frequently asked questions
How do I extract text between two characters with MID?
The start is the position of the first character plus one; the length is the difference between the two positions minus one. For text in brackets: =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1). In Microsoft 365 it is shorter: =TEXTBEFORE(TEXTAFTER(A2,"("),")").
What is the difference between MID and LEFT?
LEFT always starts at the first character; with MID you choose the start. =MID(A2,1,3) and =LEFT(A2,3) return the same result.