IF with VLOOKUP

Vlookup is simple.

You have to define the lookup value. For the first case in the line number 6, the lookup value is 2. The table, where the value is looked up is A2:B4. Column index is 2, as the values are looked up one row right from the lookup value. False means that we are looking for exact value 2 in row A not a value closest to 2. Then the VLOOKUP returns the value qw.

If VLOOKUP does not find the value 3, it returns the value #N/A. Some other value might cosmetically be better like “not found” or just blank cell.

We can use ISERROR function. The formula tells us whether the function returns a reasonable value or not.

IF the VLOOKUP returns a value with error, then print “not found” or blank. IF the VLOOKUP returns a value without error, then use the normal VLOOKUP function.

To copy paste the IF sentence:

=IF(ISERROR(VLOOKUP(A6;A2:B4;2;FALSE));”Not found”;VLOOKUP(A6;A2:B4;2;FALSE))

If a blank cell is better than any text, then just delete Not found text and use the quotation marks like “”.