[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

checking multiple values in VLOOKUP not equal

Posted on 2010-08-27
3
Medium Priority
?
451 Views
Last Modified: 2012-05-10
In order to check Anot equal to "Red" in a Vlookup statement, I would code   A,"<>Red".

Is there a way to check A not equal to "Red", "Green" or "Blue" in vlookup without repeating the criteria similar to A not in ("Red", "Green", "Blue")

The reason is that I am comparing the value to a value returned from a vlookup, so I did not want to have concatanated vlookups if possible
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
radnbne earned 1000 total points
ID: 33547849
I have taken to using worksheets to perform lookups and then referencing those in formula to keep the code cleaner.

You could also create vb function to perform the lookup and return the result.


0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33547862
You can use this
If your VLOOKUP is VLOOKUP(E5,$A$1:$B$5,2,FALSE)
You can use this expression

ISNA(MATCH(VLOOKUP(E5,$A$1:$B$5,2,FALSE),{"Red","Blue","Green"},0))

It returns True if the vlookup returns a value that is none of Red,Green,Blue
e.g.

=IF(ISNA(MATCH(VLOOKUP(E5,$A$1:$B$5,2,FALSE),{"Red","Blue","Green"},0)),"no red green or blue", "was matched")
0
 
LVL 81

Assisted Solution

by:byundt
byundt earned 1000 total points
ID: 33548079
You could also test a SUMPRODUCT formula. Using cyberkiwi's example:
=IF(SUMPRODUCT((A1:A5=E5)*(B1:B5={"red","green","blue"})),"was matched","no red, green or blue")

The SUMPRODUCT formula is a little shorter and only needs two levels of nesting (vs four for IF(ISNA(MATCH(VLOOKUP...)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question