Extract the serial from a product code (MID)

Easy Text
Description
Hints 0/4
Solutions 2
–
Test case
1
2
3
Reset
Submit
fx
A
B
C
D
E
F
G
1
2
3
4
5
6
7
8
9
10
Loading interactive spreadsheet...
Preparing grid cells and formula calculation engine
○ Ready Enter formula in highlighted cells, then click Submit.

The problem

Problem statement

Warehouse labels use one fixed format, PRD-1023-A: three letters, a dash, a four-digit serial, another dash, and a suffix letter. The packing report only needs the serial — characters 5 through 8. Fill Serial in C2:C5 from the codes in A2:A5.

MID returns text, so a serial like 0042 keeps its leading zero — case 3 is exactly that.

Problem data

Show the sheet as a table (selectable, copyable)
The exercise data, as a table
AC
1 Product codeSerial
2 PRD-1023-A
3 SRV-8841-B
4 ACC-0050-C
5 KIT-7712-D

Notes

MID(text, start_num, num_chars) returns num_chars characters beginning at start_num. The first character is position 1, not 0. In PRD-1023-A the serial occupies characters 5 through 8: MID("PRD-1023-A", 5, 4) is "1023". A hardcoded 1023 fails as soon as the code in A2 changes.

How to approach

Your answer goes in C2:C5. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.

  1. Target cells are C2:C5 — start in C2, then fill down
  2. The text to cut is A2
  3. The serial starts at character 5 and is 4 characters long
  4. MID takes three arguments: the text, the start position, and the character count

Official solutions

Show 2 solutions — try it yourself first

Approach 1: MID with a fixed start

=MID(A2, 5, 4)

Returns 4 characters of A2 beginning at position 5. PRD-1023-A yields 1023. Fill down through C5 so each code gives up its own serial.

Approach 2: MID after the first dash

=MID(A2, SEARCH("-", A2) + 1, 4)

SEARCH finds the dash; adding 1 starts on the first serial digit. The serial is still 4 characters. On these fixed-format codes the result matches =MID(A2, 5, 4).

Function guide

Related practice

FAQ

How do I extract the middle of a cell in Excel?

Use =MID(A2, 5, 4). It starts at character 5 and returns the next 4 characters. MID("PRD-1023-A", 5, 4) is "1023".

Does MID count from 0 or from 1?

From 1. The first character is position 1. MID(A2, 0, 4) returns #VALUE!.

Why did I get 0050 instead of 50?

MID returns text, so the leading zero in ACC-0050-C stays. Wrap the result in VALUE only when you need a number.