+ Reply to Thread
Results 1 to 6 of 6

VLOOKUP: search for a value within a range of cells

  1. #1
    Registered User
    Join Date
    03-13-2007
    Posts
    5

    VLOOKUP: search for a value within a range of cells

    I have a problem here. I want to do a vlookup an an array of cells but my array is complicated. I have cells in my array that is a range of values: 54820-55200 for example. This range is entered into 1 cell. I also have about 300 other cells with ranges similar to this like so:

    Column A Column B
    54820-55200 Yes
    64573-64595Yes
    93505-93562Yes
    55300-55866Yes
    64702-64726Yes
    93580-93603Yes

    I want to do a vlookup so that the value in the cell i want to lookup, let's say the value is 54821, then excel will return the value in the column next to the range (Yes in this case). If the value is 55201 then it should show a "#N/A"

    How do i do this?

    -Serwar

  2. #2
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: VLOOKUP: search for a value within a range of cells

    You could try this formula...

    Please Login or Register  to view this content.

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: VLOOKUP: search for a value within a range of cells

    or
    =IF(AND(C1>=--LEFT(A1,5),C1<=--RIGHT(A1,5)),B1,"#N/A")
    both of these depend on there being 5 digits either side of the -
    you might want to consider
    =IF(AND(C1>=--LEFT(A1,FIND("-",A1)-1),C1<=--MID(A1,FIND("-",A1)+1,255)),B1,"#N/A")
    Last edited by martindwilson; 10-20-2009 at 09:21 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VLOOKUP: search for a value within a range of cells

    I think perhaps you mean something like:

    Table: A1:B6
    Criteria: C1
    Result: D1

    D1:
    =LOOKUP(2,1/((0+LEFT(A1:A6,FIND("-",A1:A6)-1)<=C1)*(0+RIGHT(A1:A6,LEN(A1:A6)-FIND("-",A1:A6))>=C1)),B1:B6)

    Above assumes your ranges do not overlap....
    if they do the value from B is returned for the last range in which criteria is found (if first is required you can revert to an INDEX but the above is perhaps simplest)

  5. #5
    Registered User
    Join Date
    03-13-2007
    Posts
    5

    Re: VLOOKUP: search for a value within a range of cells

    The last one seemed to work. Thanks! Here's a followup question: Some of my ranges have alphanumeric values:

    G0431-G0530

    The formula doesn't seem to be working on these ranges.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VLOOKUP: search for a value within a range of cells

    You don't specify what the "criteria" value would be for your last example (ie G0440 or 440) -- assuming the former then the below should work for you

    Please Login or Register  to view this content.
    (ie make comparisons text based)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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