Function Problems

Find the First Five Matching Array Values in Excel 2019

Muhammad TalhaMuhammad Talha Nov 18, 2026 869 views

Question details

Find up to five values whose first two characters match a code in a separate list using Excel 2019.

Find the First Five Matching Array Values in 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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the match formula

In B2, enter =AND(A2<>"",SUMPRODUCT(--(LEFT(A2,2)=$E$2:$E$10),--($E$2:$E$10<>""))>0).

2
Fill the helper column

Drag the fill handle from B2 down through B100. TRUE marks a value whose first two characters match a nonblank code.

3
Filter matching rows

Select the data and its header row, choose Data > Filter, and use the filter arrow in column B to show only TRUE.

4
Take the first five values

Read or copy the first five visible values in column A. If fewer than five rows match, use the matches available.

Filter a helper column for the first five matches
Matching behavior: The formula compares the literal first two characters, ignoring case. Repeated matching values are returned as separate rows.
Work with matching values in WPS

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. 1. Open the workbook: Open your Excel workbook in WPS Spreadsheets and place values in A2:A100 and text codes in E2:E10.
  2. 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. 3. Show matching rows: Select the data and headers, choose Data > Filter, and filter column B to show TRUE.
  4. 4. Select the results: Copy the first five visible values from column A to your chosen output range.
Filter values by their first two charactersOpen and save Microsoft Excel XLSX filesWork in a familiar spreadsheet interfaceUse WPS Office for free
microsoft office alternative - wps office

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.