tags:

views:

203

answers:

2

I am having trouble in an IF STATEMENT, comparing the output of a VLOOKUP with any value object. For example

=TRIM(IF(OR(TRIM(VLOOKUP(AI11,G15:I90,3,FALSE))=K1,TRIM(VLOOKUP(AI11,G15:I90,3,FALSE))=K2),BE11,TRIM(VLOOKUP(AI11,G15:I90,3,FALSE))))

K1, K2 are value cells

NO errors are produced just incorrect values

+1  A: 

Not much to go on but having a guess at your data and incorrect values.

You are testing equality here:

TRIM(VLOOKUP(AI11,G15:I90,3,FALSE))=K1

The TRIM will cast to a string if cell K1 is evaluate as a number then the expression will return false. My assumption here is that the values in K1 and also K2 may be evaluate as numbers.

I suggest that you try evaluating K1 and K2 as strings eg.

TRIM(VLOOKUP(AI11,G15:I90,3,FALSE))=TRIM(K1)
Andrew
A: 

If you want to compare numbers, don't use Trim, since it supposed to return a string.
Try Value instead, which will return a number.
If you're using 2007 or later, you could also include an IFERROR to avoid the #N/A or other errors. If using older version, it's very simple to write your own IFERROR.

iDevlop