Nested If statement Excel - checking if value exists

KingJohnno picture KingJohnno · Jun 21, 2013 · Viewed 8.9k times · Source

I have a spreadsheet with multiple row with varying data in the collumns eg:

Student NO       Book1   Book 2    Book 3   Book 4    Book 5
  X               12
  Y               13        12        23        23        32

What I want to do is a Lookup of that mark in another table to see if the book exists, and to come back with NA if the mark isn't in the other spreadsheet.

I have the following code, although if the book isn't in the bounds then it comes back as blank. :'( is there a way to make it N/A.

=IF(ISNA(VLOOKUP(Q3,'Libary Books 21-06-13'!$A:$B,2,FALSE)),"",VLOOKUP(Q3,'Libary Books 21-06-13'!$A:$B,2,FALSE))

Many thanks

Answer

Jon Crowell picture Jon Crowell · Jun 21, 2013

Just replace "" in the Value_if_true part of your formula with "NA".

=IF(ISNA(VLOOKUP(Q3,'Libary Books 21-06-13'!$A:$B,2,FALSE)),"NA",VLOOKUP(Q3,'Libary Books 21-06-13'!$A:$B,2,FALSE))

EDIT BASED ON COMMENT: The best way to understand these kinds of nested formulas is to make them as simple as possible so that you can make sure what is happening.

I set up two columns, Book Name in column A and Nested If in column B on a single sheet.

The formula in column B is

=IF(ISNA(A2), "", IF(A2="", "Doesn't Exist", A2))

I copied and pasted that formula to all rows. Here are the results:

Book Name              Nested If
The Sun Also Rises     The Sun Also Rises
                       Doesn't Exist
#N/A               

You can use the formula above as your template.