+ Reply to Thread
Results 1 to 5 of 5

If found in range1, "a", if found in range2 "b"

Hybrid View

  1. #1
    Registered User
    Join Date
    10-06-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    35

    If found in range1, "a", if found in range2 "b"

    Just wondering if there's a better way to do this than multiple IFs.

    I want to say for each line:

    If A1 is in the list of B1:B100, return "high"; or if it's in C1:C100, return "medium"; or if it's in D1:D100, return "low"...

    The lists are too long to moosh into one tall column with a vlookup. Is there a more elegant way to do it than IF(IF(IF)))?

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: If found in range1, "a", if found in range2 "b"

    Research MATCH and VLOOKUP and HLOOKUP.

    I prefer to build things like this in steps:
    G1=if(isna(match($A1,b$1:b$100,false)),"","high")
    H1=if(isna(match($A1,c$1:c$100,false)),"","medium")
    I1=if(isna(match($A1,d$1:bd100,false)),"","low")

    if(g1, "high", if(h1, "medium", if(i1, "low","")))

    Is that too many if statment nestings?

    Also consider using B:B instead of b$1:b$100, etc.
    Chip, if you can read this, you're STILL making the world a better place with your immeasurably valuable gifts. Every week, you continue to help me (and untold numbers of others) tremendously. Practically no alternative outlets can match your effectiveness, even over the vast number of topics you demystify and empower usage of. You were, and still are, amazing.

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: If found in range1, "a", if found in range2 "b"

    If even those 3 are too many, even shortened as I have done, you can again work over multiple cells. One way:
    J1 = if(len(G1)>0,G1,"")
    K1 = if(len(J1)>0,J1,H1)
    J1 = if(len(K1)>0,K1,I1)
    But that's more awkward than even a 5 term nesting.

    Consider
    J1 = G1 & H1 & I1
    for no IFs at all. Beware if more than one column has A1's value though.

  4. #4
    Registered User
    Join Date
    10-06-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: If found in range1, "a", if found in range2 "b"

    I need it to fill columns so having it all in one cell works best.

    I guess I will use the series of IF statements. I will probably do a 4th column to check so it'll be one more level.

    Thanks for the answers.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If found in range1, "a", if found in range2 "b"

    What's wrong with something like this:

    =IF(COUNTIF(B1:B100,A1),"high",IF(COUNTIF(C1:C100,A1),"medium",IF(COUNTIF(D1:D100,A1),"low","")))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find "Apple" in ColB, then count ColC until the next "Total" is found in ColB
    By roothog in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-08-2013, 10:30 PM
  2. [SOLVED] Instead of showing #N/A and #REF!, i want the result show as "Not Found" and "Found"
    By DonnyLau in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-11-2013, 08:58 AM
  3. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  4. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  5. Replies: 2
    Last Post: 05-05-2008, 04:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1