+ Reply to Thread
Results 1 to 6 of 6

vlookup question

  1. #1
    Registered User
    Join Date
    09-03-2008
    Location
    England
    Posts
    5

    vlookup question

    At the risk of being the excel dunce and sitting in the corner wearing the d hat, I need to do the following:

    C44 will be a number ranging from 1.2 or over to -1.2 or under. I need to allocate a letter in E44 depending on C44, where A is the highest, i.e 1.2 or more, B is 1.1, C is 1 etc, down to X, which is -1.1 and Y is -1.2 or worse.

    I am sure this is extremely easy but I have faffed around trying to understand vlookups without any success. Can someone just post it for me?

    Many thanks

  2. #2
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    VLOOKUP looks at the left-most column in a rectangle of data (generally 2 or more columns) for a specific item that you specify, then goes over to the right a specific number of columns (that you also specify) from that specific item and gives you the data from that cell. So, the function requires a lookup value (the specific item), the range (the rectangle), and the column index number (the number of columns over to the right). You can also specify whether you want it only to look for an exact value or whether you want it to find the closest value that's less than or equal to the value you specify (obviously, this would only work with numerical items).

    In the range A1:B25, you would put a lookup table like this:

    -1.2 Y
    -1.1 X
    -1 W
    -0.9 V
    -0.8 U
    -0.7 T
    -0.6 S
    -0.5 R
    -0.4 Q
    -0.3 P
    -0.2 O
    -0.1 N
    0 M
    0.1 L
    0.2 K
    0.3 J
    0.4 I
    0.5 H
    0.6 G
    0.7 F
    0.8 E
    0.9 D
    1 C
    1.1 B
    1.2 A

    And, in E44, you would put this equation:
    =VLOOKUP(C44,A$1:B$25,2,TRUE)

    EDIT:
    actually, I should have tested this first... the equation won't work for scores <-1.2, so you would need some kind of workaround; the first thing that comes to mind is using this equation instead:

    =IF(C44<-1.2,"Y",VLOOKUP(C44,A$1:B$25,2,TRUE))

    or you can use the orginal equation and add a top row to the lookup table like this (or replace -1000 with whatever the minimum possible score is)
    -1000 Y
    and the rest of your table would come after this
    -1.2 Y
    -1.1 X
    etc...
    change the range in your VLOOKUP to A$1:B$26
    Last edited by clownfish; 01-02-2009 at 09:09 AM.

  3. #3
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    the solution given may work, but Rothmans has not specified the ranges. -1.15 will give an answer of Y above. and -1.3 will cause an error. Rothmans needs to be more explict with their question for the answers and in which range the boundary points fall eg

    >1.2
    >1.1 but <=1.2

    But Vlookup will be the basis of the result. they have asked for an impossbile solution as 26 criteria are meant to be represented by 25 letters!

    Regards

    Dav
    Last edited by Dav; 01-02-2009 at 09:15 AM.

  4. #4
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    another option, which will totally avoid a lookup table:

    =IF(ISBLANK(C44),"",IF(C44<-1.2,"Y",IF(C44>1.2,"A",MID("YXWVUTSRQPONMLKJIHGFEDCBA",INT(C44*10+13),1))))

    note that this will, in effect, ignore digits beyond the first decimal place, so a score of 1.15 will be the same as 1.1, 1.11, 1.19, etc. (all will be 1.1). If you would prefer rounding, you can use this:

    =IF(ISBLANK(C44),"",IF(C44<-1.2,"Y",IF(C44>1.2,"A",MID("YXWVUTSRQPONMLKJIHGFEDCBA",ROUND(C44*10+13,0),1))))
    Last edited by clownfish; 01-02-2009 at 11:07 AM.

  5. #5
    Registered User
    Join Date
    09-03-2008
    Location
    England
    Posts
    5

    He's no clown!

    Excellent, I think the last edit from Clownfish worked with the rounding. Dav was correct as there were errors when I first tried it.

    Many thanks Guys, much appreciated.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Here's another way

    =IF(C44="","",CHAR(MEDIAN(65,89,77-ROUND(C44*10,0))))
    Last edited by daddylonglegs; 01-02-2009 at 10:24 AM.

+ 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