Use INDEX and MATCH to Recode Survey Rankings in Excel
Question details
Find each fruit within a grouped survey response and return the ranking assigned to its group using Excel INDEX and MATCH formulas.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Grouped fruit responses appear in columns A:D, their corresponding rankings appear in columns E:H, and individual fruit names are headers in I1:O1.
- Observed behavior
- Each output cell should display the ranking of the group containing the fruit named in its column header.
Check that each group in A:D has its corresponding ranking in the same relative position in E:H: A pairs with E, B with F, C with G, and D with H. Enter individual fruit names in I1:O1 and check that their spelling matches the response text.
Return each fruit's group ranking with INDEX and MATCH
Use this formula when fruit names are embedded in grouped response text and you want one ranking column per fruit.
MATCH searches A2:D2 for text containing the fruit named in the output header. INDEX then returns the ranking at the same position in E2:H2. The dollar signs keep the source columns and header row fixed while allowing the formula to adjust as you fill it.
Select cell I2, enter =INDEX($E2:$H2,MATCH("*"&I$1&"*",$A2:$D2,0)), and press Enter. The asterisks let MATCH find the header's fruit name anywhere within a grouped response.
Select I2 and drag its fill handle right through O2. Each output column will use its own fruit header while continuing to search columns A:D and return rankings from E:H.
Select I2:O2 and drag the fill handle down to the last survey row. Check a few results against the original groups and rankings to confirm the column pairing.

Show a readable result when a fruit is not found
Use IFNA around the formula if some survey rows do not contain every fruit.
Map Grouped Survey Responses to Fruit Rankings in WPS Spreadsheet
Use INDEX and MATCH in WPS Spreadsheet to find a fruit within grouped response text and return its corresponding ranking. Fill the formula across fruit headers and down the survey rows.
- 1. Open your survey workbook: Launch WPS Spreadsheet and use Menu > Open to select your Excel workbook.
- 2. Check the response layout: On the survey sheet, confirm that grouped responses are in A:D, corresponding rankings are in E:H, and individual fruit names are in I1:O1.
- 3. Enter the ranking formula: Click I2, type =INDEX($E2:$H2,MATCH("*"&I$1&"*",$A2:$D2,0)), and press Enter.
- 4. Fill and save the results: Drag the fill handle from I2 through O2, then select I2:O2 and fill down to the last survey row. Use Menu > Save As and choose .xlsx to keep the workbook in an Excel-compatible format.

Frequently Asked Questions
Why does the formula use asterisks around the fruit name?
In MATCH("*"&I$1&"*",$A2:$D2,0), each asterisk represents any sequence of characters. This allows a header such as Apple to match a cell containing Apple, Banana rather than requiring the entire cell to equal Apple.
Why am I getting #N/A for a fruit?
MATCH returns #N/A when none of the cells in that row's A:D range contains the header's fruit name. Check the header spelling and response text. To show a readable label, enter =IFNA(INDEX($E2:$H2,MATCH("*"&I$1&"*",$A2:$D2,0)),"Not found") in I2.
What happens if a fruit appears in more than one group?
MATCH searches A:D from left to right and returns the first matching position. The formula therefore returns only the first matching group's ranking, not every ranking. Review or resolve duplicate fruit entries if each fruit should belong to one group.
How do the dollar signs help when I fill the formula?
$A2:$D2 and $E2:$H2 keep the source columns fixed while allowing the row number to change when you fill down. I$1 keeps the header row fixed while allowing the header column to change when you fill right.
Can Apple accidentally match Pineapple?
Yes. The pattern *Apple* matches any text containing Apple, including Pineapple, because MATCH is not case-sensitive and the formula does not check word boundaries. Inspect the labels in A:D before filling the formula; overlapping names require a delimiter-aware approach or a normalized table with one fruit per entry.




