Question

I'm trying to work out a formula for combining an IF statement and a VLOOPUP.

Basically, I want the formula to return a value if a value was found through VLOOKUP, or to return something else if not found...

I have experimented with

=IF(VLOOKUP(A1,$B$2:$B$31, 1, 0),"FOUND","NOT FOUND!")

... but this doesn't seem to work.

Many thanks for any thoughts you might have...

Was it helpful?

Solution

An old thread but would like to submit a cleaner solution for the Vlookup example or places where you want to use the value returned by a formula-

=IFERROR(VLOOKUP(A1,$B$2:$B$31, 1, 0),"NOT FOUND")

OTHER TIPS

If you just want to check whether A1 exists in B2:B31 then VLOOKUP isn't required. Either use MATCH like this

=IF(ISNUMBER(MATCH(A1,$B$2:$B$31,0)),"FOUND","NOT FOUND")

or shorter with COUNTIF

=IF(COUNTIF($B$2:$B$31,A1),"FOUND","NOT FOUND")

ISERROR() can test to see if a formula generates an error or not.

In this case, IF and VLOOKUP can be combined using

=IF(ISERROR(VLOOKUP(A1,$B$2:$B$31, 1, 0)),"NOT FOUND!", "FOUND")
=IF(ISNUMBER(MATCH(
C2,IMPORTRANGE("URL","Sheet1!B2:B2000"),0)),"FOUND","NOT FOUND")

If the matching data is in another file we can use the above formula.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top