While developing a spreadsheet that used the LOOKUP function I discovered what appears to be a bug (possibly a rounding error) in Excel. Also, as I have not checked on Windows, this is a Mac OSX issue (Snow Leopard at least). Below I present the error and the solution:
The LOOKUP function will not recognize the value in a cell in a reference column that was calculated by the product of some value and 0.55, for example 200 * 0.55.
Adjust the calculation to not include a fraction and it works fine. For example if 200 * 0.55 was used, (200 / 100) * 55 could be used instead.
The LOOKUP function can be used to retrieve a value from a column of values based on a supplied numerical value. For example, think of a grade sheet for a class where numerical values are converted to letter grades (this is what I was using it for). A column on one part of the spreadsheet contains the letter grades: A+, A, A-, B+, B, … etc., with numbers in an adjacent column that indicate the minimum numerical grade needed to obtain a particular letter grade. Suppose you want to dynamically update the table based on the total marks for a particular assignment, so for example, if the assignment was out of 100 points, with a passing grade being the 50% mark, 50 points would be needed for a C-. 55 points would be needed for a C, etc. The values in the lookup table may have a calculation for these two columns that looked like:
|100 * .50||C-|
|100 * .55||C|
Obviously, 50 and 55 could be entered directly, but replace “100″ with a reference to another cell that had the total points for the assignment and the sheet could be updated to reflect different assignment totals without needing to re-enter the values in the grade table. Unfortunately, when a value of 55 is looked up in the table, it will return a C- instead of a C! As described above, removing the decimal value in the calculation will solve this, so (100/100) * 55 can be used instead (which in this example does not make much sense, since 100/100 is 1, but imagine one of those values references another cell with the assignment marks total).
The following image shows two lookup tables that map the first letters of the alphabet to numerical values. The entry above the tables (above the space) are looking up a letter based on the value 55 in the table below. The left table uses a decimal value in it’s numerical calculation and the right table uses whole numbers. Notice that a value of 55 returns the correct letter on the right side (B) and the incorrect letter on the left side (A), which is actually the value above the one that is needed (to avoid confusion, this example is not a table of grades).