Find the First Five Matching Array Values in Excel 2019
Question details
Find up to five values whose first two characters match a code in a separate list using Excel 2019.

- Product
- Microsoft Excel 2019
- Device & OS
- not provided
- Scenario
- Compare a column of values with a list of two-character codes and return the first five matching values.
- Observed behavior
- The desired result is a list of up to five matching values in their original row order.
Place the values in A2:A100 and the two-character codes in E2:E10, adjusting the formulas if your ranges differ. Store codes as text, especially when they contain leading zeros, and keep the data in the order in which you want matches returned.
Filter a helper column for the first five matches
Use this straightforward Excel 2019 method when you are happy to identify or copy the first five filtered rows.
In B2, enter =AND(A2<>"",SUMPRODUCT(--(LEFT(A2,2)=$E$2:$E$10),--($E$2:$E$10<>""))>0).
Drag the fill handle from B2 down through B100. TRUE marks a value whose first two characters match a nonblank code.
Select the data and its header row, choose Data > Filter, and use the filter arrow in column B to show only TRUE.
Read or copy the first five visible values in column A. If fewer than five rows match, use the matches available.

Extract the first five matches with formulas
Use this method when you want the matching values to appear automatically in a separate range.
Find matching values with WPS Spreadsheets
Use a helper formula and filter in WPS Spreadsheets to identify values that begin with a code and select the first five matches.
- 1. Open the workbook: Open your Excel workbook in WPS Spreadsheets and place values in A2:A100 and text codes in E2:E10.
- 2. Add the helper formula: In B2, enter =AND(A2<>"",SUMPRODUCT(--(LEFT(A2,2)=$E$2:$E$10),--($E$2:$E$10<>""))>0), then fill it down to B100.
- 3. Show matching rows: Select the data and headers, choose Data > Filter, and filter column B to show TRUE.
- 4. Select the results: Copy the first five visible values from column A to your chosen output range.

Frequently Asked Questions
Does Excel 2019 support the FILTER function?
Excel 2019 does not include the FILTER worksheet function. Use Data > Filter with a helper column, or use the AGGREGATE extraction formula instead.
How do I keep a code such as 01 from losing its leading zero?
Format the code cells as Text before entering the codes, or type an apostrophe before each code, such as '01. The apostrophe will not appear as part of the displayed value.
What happens if there are fewer than five matches?
The filtered list shows only the matching rows. With the extraction formula, unused result cells in C2:C6 remain blank.
Are matches returned in alphabetical order?
No. Both methods use the source-row order. Sort the source data first if you want the first five matches in a different order.




