+ Reply to Thread
Results 1 to 8 of 8

Lookup & unmatches lookup value

  1. #1
    Registered User
    Join Date
    12-26-2009
    Location
    everywhere but nowhere
    MS-Off Ver
    Excel 2003
    Posts
    15

    Lookup & unmatches lookup value

    Hello everyone, ive got a question about lookup, in lookup function there is a remarks that say :

    "If LOOKUP can't find the lookup_value, it matches the largest value in lookup_vector that is less than or equal to lookup_value."

    "If lookup_value is smaller than the smallest value in lookup_vector, LOOKUP gives the #N/A error value."

    how can i get the result to be "You have type the wrong data" if i've type that doesnt match the list of the lookup value ?
    Last edited by verisme; 01-04-2010 at 08:35 AM. Reason: solved

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Lookup & unmatches lookup value

    try

    =IF(ISNA(LOOKUP(a1,b1:b100)),"you have the wrong data type",LOOKUP(a1,b1:b100)))

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Lookup & unmatches lookup value

    If you posted examples of your actual lookup formulas, this would be easier, but there are multiple ways to do this, all involve NOT using the LOOKUP() formula.

    Rather, you would use VLOOKUP(), HLOOKUP() or INDEX/MATCH().

    If your original formula looked like this:

    =LOOKUP(A1, C1:C100, D1:D100)

    ...then you could replace that with:

    =IF(ISNUMBER(MATCH(A1, C1:C100, 0)), INDEX(D1:D100, MATCH(A1, C1:C100, 0)), "Wrong data")

    Another benefit of this formula is the data no longer has to be sorted in any way.

    ==========
    Teylyn, yours would still return wrong results unless the search value is LESS than the value in B1.
    Last edited by JBeaucaire; 01-03-2010 at 02:52 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    12-26-2009
    Location
    everywhere but nowhere
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Lookup & unmatches lookup value

    thanks everyone ! for the answer
    this is my formula lookup

    =LOOKUP(F7,Sheet1!$B$3:$B$50,Sheet1!$A$3:$A$50)

    if i've type the data "LOST" but the lookup value is "LOST IN EXCEL" then what function should i use, and if the data that i've type is same as the lookup value i want the result value that turns up.
    Last edited by verisme; 01-03-2010 at 03:11 AM.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Lookup & unmatches lookup value

    To search within variable length text strings, maybe this:

    =INDEX($A$1:$A$50,SUM(--ISNUMBER(SEARCH(F7,$B$1:$B$50))*ROW($B$1:$B$50)))

    ...confirmed by pressing CTRL-SHIFT-ENTER to activate an array. If you just press ENTER, it won't work and you'll get an error. Using CTRL-SHIFT-ENTER will cause curly braces { } to appear around your formula to indicate the array is active.

  6. #6
    Registered User
    Join Date
    12-26-2009
    Location
    everywhere but nowhere
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Lookup & unmatches lookup value

    sorry, i think that you misunderstanding what i want, this is the example of my formula and what i want, please have a look and tell me the solution.
    Attached Files Attached Files

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Lookup & unmatches lookup value

    Hi,

    the way your data is layed out, you can try this formula:

    Please Login or Register  to view this content.
    If you swap the columns in Sheet1, so that the text is in column A and the numbers are in column B you can use a simple Vlookup instead of INDEX/MATCH, like this

    Please Login or Register  to view this content.
    hth

  8. #8
    Registered User
    Join Date
    12-26-2009
    Location
    everywhere but nowhere
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Lookup & unmatches lookup value

    thanks a lot @teylyn that solve my problem !.

+ 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