A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Glad you got your formula to work. You commented to me and to Snow Lu that you didn't understand why it was working the way it did without the last parameter. Here is a hopefully simple explanation.
That last element determines whether Excel will look for an exact match or the closest match that must be in an alphabetized list. So, when the formula is set to 1 (or TRUE) Excel will not go down the list any further than the first occurrence of the letter that comes after the first letter of the lookup value. When it finds that letter it will choose the item right before that letter as the closest match. If things are not in alphabetical order, then Excel may stop looking for the Lookup Value well before it gets down to the actual match.
I mentioned putting FALSE at the end in that place. Snow Lu put a 0 in that place. For this formula FALSE and 0 mean the same which is to look for an exact match and the data does not need to be alphabetized. TRUE and 1 mean the same that it will look for the closest match and MUST be alphabetized.
TRUE or 1 is the default if the element is left out which is why your formula was defaulting to the closest match as Excel interpreted it and producing the wrong outcome.
Here is an example. With a 1 (or TRUE) the formula is looking up Red in the table in A and B but getting the wrong result because, since it is set to look for the closest match in an alphabetized list, Excel stops when it gets to the Y in Yellow because it is after the R in Red in the alphabet and chooses the entry right before it.
When the Range Lookup element is changed to 0 (or FALSE) then the formula will find the correct result even though it is not alphabetized since it is now only looking for an exact match.
In addition, if Excel doesn't find an exact match in this case it will show that it can't with #N/A.