How to Use the MATCH Function to Compare Lists in Excel 2007 and Excel 2010 With Examples
In this article, I will look at how to use the MATCH function to compare lists with an example to illustrate how to use it. The MATCH function takes an item and compares it to a list and tells you the items relative position in that list.
The example I will use is a football (soccer) league table. The results will ultimately allow me to show whether teams in the league are going up or down over time.
- I will use the MATCH function to determine a team's position in the league for both this week and last week's league
- Nested IF statements are then used to determine if a teams position changed from one week to the next
- We will then use Conditional Formatting with an Icon Set to visually show the team’s position in the table compared to the previous table
Once completed, our league table will look like this:
I have another article that illustrates how to use the MATCH function, this time to create Top Ten lists. I use the MIN, MAX, SMALL and LARGE functions alongside MATCH and INDEX to create the lists. My article can be found here.
Further information on using nested IF statements as well as using the logical functions AND OR and NOT with IF, as well as using IFERROR to suppress expected errors can be found in my article here.
Using the MATCH function in Excel 2007 and Excel 2010
The MATCH function in Excel lets you look for an item in a list and tells you its relative position in that list. Using an example:
This formula will look for the contents of E3 (Doncaster Rovers) in the rangeE3–E26. The 0 at the end of the formula (known as the Match Type) tells Excel to only look for an exact match.
The result of our formula is 1 as Doncaster Rovers is the first item in the list.
Note: if Match Type equals 1, MATCH will find the largest value that is less than or equal to the value you are asking Excel to look for. The list you are asking Excel to look in must be in ascending order.
Note: If Match Type equals -1, MATCH will look for the smallest value which is greater than or equal to the value you are interested in. The list in this instance must be in descending order.
Note: if Match Type equals 0, MATCH will look only for an exact match. If the item you are asking Excel to find or the items in the list do not match exactly, then MATCH will fail to find it in the list. Use the TRIM function to remove all spaces from text.
To complete the formulas for the entire list, copy or drag the formula down to the remaining cells.
Note: the use of the $ in this formula as these are particularly important. These ensure that the list remains the same throughout and the only thing that changes is the row number of the item you are asking Excel to match.
In order to calculate last weeks table positions, use the same formula as above, just change the list Excel is looking at.
When completed, the matches for each team for this week and last week will appear in the cells Q3 to Q26 and R3 to R26.
Using Conditional Formatting and Icon Sets to Display Results of the MATCH Function in Excel 2007 and Excel 2010
The next step in our example is to convert the two lists of the MATCH results into something that we can use so that Conditional Formatting can show us how each team performs week to week.
Note: Unfortunately, you cannot use Icon Sets with formulas, so we need to convert the results into something that will work with them.
To do this, we use nested IF statements. The equation we will use in column S is:
=IF(R3>Q3, "3", IF(R3=Q3,"2",IF(R3<Q3,"1")))
So if a team goes up from one week to the next, it gets a 3 in column S. It gets 2 if there is no change and 1 if it drops.
- Copy the formula to the rest of the cells so that each item gets a 1, 2 or 3 depending on its performance.
Now we need to convert these values to numbers.
- Select them all
- Right click and select Format Cells
- Select Number under Category
- Set Decimal Places to 0
Unfortunately, Icon sets will not work with the results of a formula either, so to resolve this:
- Select the cells and right click
- Choose Copy
- Click on where you want your Icon Set to be and choose Paste Special
- Select Paste Values
Now we have a column of numbers which we don’t want to see. To hide them:
- Select them all
- Right click and select Format Cells
- Click on Custom
- Type in three semi-colons
- Press OK
This will hide the contents of the cells, unless they are clicked on
Finally, we now have data that Conditional Formatting can use with Icon Sets. Now we need to create our Conditional Formatting. To do this:
- Select the data (A3–A26 in my example)
- On the Home tab in the Styles Group, click the Conditional Formatting button
- Click New Rule
- Leave Select a Rule Type as Format all cells based on their values
- Under Format Style, select Icon Sets
- Change Type to Number for both Green and Yellow
- For Green, type 3 into Value and for Yellow type 2
- Finally, choose 3 Arrows (coloured) for your Icon Style
You should end up with the below:
The MATCH function allows us to find out where an item appears in a list relative to other items. Using an example of a football (soccer) league table we were able to determine if a team went up or down in the league over time using MATCH to compare lists. We then used nested IF statements to convert these results to a number which we could display visually using Conditional Formatting Icon Sets. The spreadsheet when completed looked like this:
I hope that you found this article useful and informative and that you have discovered how powerful the MATCH function is and how to use it in your own spreadsheets. Please leave any comments you may have below and thanks for reading!
This article is accurate and true to the best of the author’s knowledge. Content is for informational or entertainment purposes only and does not substitute for personal counsel or professional advice in business, financial, legal, or technical matters.