+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    05-06-2008
    Posts
    19

    VLOOKUP and RIGHT

    I seem cannot get the code right, see below.

    Cell: A3= Week 5

    =VLOOKUP(RIGHT($A$3,LEN($A$3)-5),Lane!$A$9:$AD$20,3)

    It won't work....

    However, if I tried as follows,
    =VLOOKUP(5,Lane!$A$9:$AD$20,3) OR
    =RIGHT($A$3,LEN($A$3)-5)
    Both works fine!!!

    But I do rather something like as it is shown on the above in RED TEXT

    Also I am worried if I have Week 10 the output will look as 0 instead of 10 so please advise what is the right code.

    Thank you for your help.
    Last edited by holiday4ever; 07-05-2009 at 04:45 AM.

  2. #2
    Registered User
    Join Date
    07-03-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VLOOKUP and RIGHT

    The problem here is the distinction between numbers and text strings.

    The RIGHT function is returning the text string "5". But your column of numbers doesn't contain "5" it only contains the number 5.

    To convert a text string into a number use VALUE. E.g. VALUE("5") = 5.

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

    Re: VLOOKUP and RIGHT

    Just add - -
    =VLOOKUP(--RIGHT($A$3,LEN($A$3)-5),$A$9:$AD$20,3,false)
    Mojito connoisseur and a dabbler in Cisco
    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
    Registered User
    Join Date
    05-06-2008
    Posts
    19

    Re: VLOOKUP and RIGHT

    Thanks Ancalagon12321 and martindwilson. I add "VALUE" see following details....

    =VLOOKUP(VALUE(RIGHT($A$3,LEN($A$3)-5)),Lane!$A$9:$AD$20,3)

    =VLOOKUP(VALUE(--RIGHT($A$3,LEN($A$3)-5)),Lane!$A$9:$AD$20,3,FALSE)

    Both works fine. Thank you very much.
    Last edited by holiday4ever; 07-04-2009 at 08:50 PM. Reason: To correct my answer

  5. #5
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: VLOOKUP and RIGHT

    you dont need "value"
    Mojito connoisseur and a dabbler in Cisco
    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

  6. #6
    Registered User
    Join Date
    07-03-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VLOOKUP and RIGHT

    martin:

    True, but you don't need "--" either

    I prefer using VALUE because double-minus only "just so happens" to work, thanks to Excel's implicit type-casting rules, whereas the VALUE function was put there for express purpose of turning text into numbers.

    So I think using VALUE is clearer for any non-Excel-guru who has to understand and maintain the formulas.

  7. #7
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: VLOOKUP and RIGHT

    piffle and balderdash !
    Mojito connoisseur and a dabbler in Cisco
    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

  8. #8
    Registered User
    Join Date
    05-06-2008
    Posts
    19

    Re: VLOOKUP and RIGHT

    Thanks again to you both for pointing this out, martindwilson yeah you are right I do can do without the value. So I understand that I can use either of them. I am looking to improve my knowledge especially in Excel formulas and functions so I am wondering could anyone send a private email of recommended books to me. Thanks

  9. #9
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2003, 2007
    Posts
    355

    Re: VLOOKUP and RIGHT

    holiday4ever
    If that takes care of your need, Plz, EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

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.2.0