View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default vlookup does not work between 71% to 79% refernceing roundup n

Glennrbt wrote...
....
Say that in cell A1 I enter a value. In cell A4 I will round down that value
(=ROUNDDOWN(A1,1)). In cell A5 I will roundup the value (=ROUNDUP(A1,1)).
In cell B4 I have (=VLOOKUP(A4,CHART,B2)), In cell B5 I have
(=VLOOKUP(A5,CHART,B2)). This works great till I have a value in cell A1
between 71% to 79%. If I enter the value in cell A5 manually and over ride the
roundup function, VLOOKUP finds the proper value.


Presumably CHART refers to a range spanning multiple columns.

Anyway, I was able to reproduce this error. The formula

=VLOOKUP(ROUNDUP(0.76,1),{0.75;0.8},1)

returns 0.75 rather than 0.8, but the formula

=VLOOKUP(ROUND(0.76,1),{0.75;0.8},1)

returns 0.8. Very odd because

=ROUND(0.76,1)=ROUNDUP(0.76,1)

returns TRUE. However, the formula

=VLOOKUP(ROUNDUP(0.76,1)-ROUND(0.76,1),{-1;0},1)

returns -1, so this could be called a bug in VLOOKUP. However, the root
cause is floating point rounding error. Excel usually applies a fudge
factor to handle very small differences, but it seems the first
argument to VLOOKUP (and HLOOKUP and LOOKUP) apprears to be one case in
which the fudge factor isn't applied. Back to old-fashioned floating
point techniques - depend on exact equality, figure out some small
amount that constitutes 'close enough', and add it to comparisons, so
if that value were 1E-12, try

=VLOOKUP(A5+1E12,CHART,B2)