Text
Taking the middle of a code
Definition
Taking characters from the middle of a code means giving MID the text, the start position, and how many characters to return.
Syntax
=MID(text, start_num, num_chars)
Arguments
| Argument | Meaning |
|---|---|
text |
The cell that holds the full code. |
start_num |
The position of the first character to take. Position 1 is the first character. |
num_chars |
How many characters to return from that start point. |
Worked example
A depot lists pallet tags in B2:B4. The batch number sits in the middle of each tag.
| A: Aisle | B: Tag |
|---|---|
| North | PX-8821-K |
| East | PX-4409-K |
| West | PX-1170-K |
Formula: =MID(B2,4,4)
Result: 8821. Position 4 of PX-8821-K is 8, and the next four characters are 8821.
Practice
Cell A2 holds AB12CD. In B2, write a formula that returns 2 characters from A2, starting at position 3.
- In B2, write a MID formula that takes 2 characters of A2 starting at position 3.
- B2 should show 2 characters of A2 starting at position 3.
Step 1 of 2
Enter =MID(A2,3,2) in B2.
A2 is AB12CD, so 2 characters starting at 3 are 12.
Formulas here use English function names, such as SUM, and a period as the decimal separator, in every language.
Loading the sheet…
B2 uses MID.
B2 now shows 12.
The next lesson is Finding where a letter sits.
Related functions
MID is the function that pulls that slice from inside the code.
Common mistake
Counting from 0, as in =MID(B2,3,4): position 3 of PX-8821-K is the hyphen, so the result is -882 instead of 8821.