There are times when you want to return a match for a VLOOKUP based on more than one value. For example, we may have customers who have multiple branches. Each branch is recorded under the same customer number. So how do we look up info for a specific branch if all of the branches are using the same customer number?
In the example below you will see that each branch of the same company has the same ‘Customer No’. Therefore if we need to find a match based on the ‘Customer No’ AND the ‘Branch’ we can use the CONCATENATE function to pull these two values together to be used for the Lookup Value. This then allows us to utilise the VLOOKUP function.
Using the CONCATENATE function to join the values
The CONCATENATE function offers the ability to combine data held in separate cells into the same cell. Each single cell reference can be pulled together into a single string.
In the example above the Concatenate function is used to combine the content from column A and column G. For example, in cell B14 the formula is =CONCATENATE(A14,G14). This then creates the unique value of CustomerNoBranch.
In cell E9 the CONCATENATE function is used to pull the ‘Customer No’ in cell E4 and the ‘Branch’ in cell E5 together. This is then used to find an exact match in column B.
If at any time the data in cell E4 or E5 changes the result will be updated.
Hiding #N/A errors when the VLOOKUP value isn’t found
The model above is reliant on the user entering both the customer number and branch correctly. If the data is entered incorrectly the #N/A (Not Available) error will be displayed.
To avoid this try using the IFERROR functionto replace the errors with a prompt. In the example below if the lookup value can’t be found the text “not found’ will be displayed instead.
Vlookup tip: When you count your columns to get the ‘Column_index_num’ be sure to include hidden columns as well. If the ‘Table_array’ includes numerous columns (including hidden columns) try numbering your columns in a row above (as shown in row 12 above). It then becomes very easy to identify the ‘Column_index_num’ of the column you want to look up.
We cover look up functions in our Excel Data Reporting course. If you are dealing with large data lists this course is definitely for you.
If you found this post helpful please ‘Like’ us!
If you enjoyed this post you may enjoy:
- Hiding errors in Excel using the IFERROR function
- How do I sum a range of cells in Excel that include #N/A or #DIV/0! errors?
- Excel – Using VLOOKUP to compare two lists
- How can I create a list of Weekdays only in Excel?