Extract W320 from Text with an Excel MID Formula
Question details
Extract a four-character product code such as W320 from a cell containing a longer description.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A product description contains a space-separated code beginning with W, such as W320.
- Observed behavior
- The desired result is W320 from the text “VIETNAMESE CASHEW KERNEL W320 HSCODE 080132.”
Place the source text in a cell, such as A1, and check that the code is a four-character word separated by spaces. The formula below finds the first matching four-character word beginning with W; it does not verify that the last three characters are digits.
Extract a space-separated W code with MID and SEARCH
Use this formula when another word, such as CASHEW, contains W before the product code.
Place the product description in cell A1.
Select an empty cell, enter =MID(" "&A1&" ",SEARCH(" W??? "," "&A1&" ")+1,4), and press Enter.
Confirm that the formula returns W320 for the example text. Drag the fill handle down to apply it to other rows.

Extract four characters from the first W
Use the shorter formula only when the product code begins at the first W in the cell.
Extract W320 with MID and SEARCH in WPS Spreadsheet
Use the same MID and SEARCH formula in WPS Spreadsheet to extract a space-separated product code from a longer description.
- 1. Open the spreadsheet: Open WPS Spreadsheet and place the product description in cell A1.
- 2. Enter the formula: Select an empty cell and enter =MID(" "&A1&" ",SEARCH(" W??? "," "&A1&" ")+1,4).
- 3. Apply the formula: Press Enter to return W320, then drag the cell’s fill handle down to extract codes from additional rows.
- 4. Save the workbook: Choose File > Save As and select an Excel workbook format such as XLSX if you need to share it with Excel users.

Frequently Asked Questions
Why does searching for the first W not return W320?
In the example, CASHEW contains an earlier W. Use =MID(" "&A1&" ",SEARCH(" W??? "," "&A1&" ")+1,4) to find the first space-separated four-character word beginning with W instead.
What happens if there is no matching code?
SEARCH returns a #VALUE! error. To show a blank instead, use =IFERROR(MID(" "&A1&" ",SEARCH(" W??? "," "&A1&" ")+1,4),"").
Does the formula work if W320 is at the start or end of the text?
Yes. The formula adds a space to each end of the text before searching, so a four-character code at either boundary can match.
Does the formula require the last three characters to be numbers?
No. The three question marks match any three characters, so a different four-character word beginning with W could be returned if it appears first.




