+ Reply to Thread
Results 1 to 7 of 7

VLOOKUP function

  1. #1
    L. Chung
    Guest

    VLOOKUP function

    There is a table as below:

    A B
    1 11 20
    2 12 21
    3 12 22
    4 13 23
    5 12 24

    If I input the function "=vlookup(12,A1:B5,2,0)", the result would be "21"
    since Excel would find the first "12" (wich is in cell A2) in column A.
    However, when I would like to find the last "12" (which is in cell A5) in
    column A, that is the answer "24"(in cell B5) is required, how can I modify
    the function? Please help me.

  2. #2
    DReims
    Guest

    RE: VLOOKUP function

    Inverse the table order and then do a vlookup.

    5 12 24
    4 13 23
    3 12 22
    2 12 21
    1 11 20

    Vlookup will then return the 1st lookup that works. Having inversed the
    table, you are really getting the last match!



    "L. Chung" wrote:

    > There is a table as below:
    >
    > A B
    > 1 11 20
    > 2 12 21
    > 3 12 22
    > 4 13 23
    > 5 12 24
    >
    > If I input the function "=vlookup(12,A1:B5,2,0)", the result would be "21"
    > since Excel would find the first "12" (wich is in cell A2) in column A.
    > However, when I would like to find the last "12" (which is in cell A5) in
    > column A, that is the answer "24"(in cell B5) is required, how can I modify
    > the function? Please help me.


  3. #3
    RagDyeR
    Guest

    Re: VLOOKUP function

    This *array* formula will give you the *last* match in the column:

    =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))

    Array formulas are entered using CSE, <Ctrl> <Shift> <Enter>, instead of the
    regular <Enter>, which will *automatically* enclose the formula in curly
    brackets, which *cannot* be done manually.

    --

    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================


    "L. Chung" <L. [email protected]> wrote in message
    news:[email protected]...
    There is a table as below:

    A B
    1 11 20
    2 12 21
    3 12 22
    4 13 23
    5 12 24

    If I input the function "=vlookup(12,A1:B5,2,0)", the result would be "21"
    since Excel would find the first "12" (wich is in cell A2) in column A.
    However, when I would like to find the last "12" (which is in cell A5) in
    column A, that is the answer "24"(in cell B5) is required, how can I modify
    the function? Please help me.



  4. #4
    L. Chung
    Guest

    Re: VLOOKUP function

    There is another question and using same table again:

    A B
    1 11 20
    2 12 21
    3 12 22
    4 13 23
    5 12 24

    By using below formula,

    =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))

    I can find the *last* match in the column. However, if I can't find the
    lookup value (e.g. 15) in Column A, "#N/A" will be shown and I would like to
    assign the value "30" to it instead of showing "#N/A". However, if the lookup
    value in column A (e.g. 12) can be found, the corresponding value in column B
    (result of 24) is needed.

    So, How can I modify this formaula. And thank you all.



    "RagDyeR" wrote:

    > This *array* formula will give you the *last* match in the column:
    >
    > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    >
    > Array formulas are entered using CSE, <Ctrl> <Shift> <Enter>, instead of the
    > regular <Enter>, which will *automatically* enclose the formula in curly
    > brackets, which *cannot* be done manually.
    >
    > --
    >
    > HTH,
    >
    > RD
    > ==============================================
    > Please keep all correspondence within the Group, so all may benefit!
    > ==============================================
    >
    >
    > "L. Chung" <L. [email protected]> wrote in message
    > news:[email protected]...
    > There is a table as below:
    >
    > A B
    > 1 11 20
    > 2 12 21
    > 3 12 22
    > 4 13 23
    > 5 12 24
    >
    > If I input the function "=vlookup(12,A1:B5,2,0)", the result would be "21"
    > since Excel would find the first "12" (wich is in cell A2) in column A.
    > However, when I would like to find the last "12" (which is in cell A5) in
    > column A, that is the answer "24"(in cell B5) is required, how can I modify
    > the function? Please help me.
    >
    >
    >


  5. #5
    RagDyer
    Guest

    Re: VLOOKUP function

    Are we both talking about the same formula???

    The formula I suggested will *not* return a #N/A error if the lookup value
    is not found in Column A.
    It *will* return a #NUM! error though!

    Anyway, to eliminate the #NUM! error, you can try this *array* formula:

    =IF(ISNA(MATCH(12,A1:A15,0)),30,INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15))
    ,1)))

    --
    Array formulas must be entered with CSE, <Ctrl> <Shift > <Enter>, instead
    oft the regular <Enter>, which will *automatically* enclose the formula in
    curly brackets, which *cannot* be done manually.
    --
    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================

    "L. Chung" <L. [email protected]> wrote in message
    news:[email protected]...
    > There is another question and using same table again:
    >
    > A B
    > 1 11 20
    > 2 12 21
    > 3 12 22
    > 4 13 23
    > 5 12 24
    >
    > By using below formula,
    >
    > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    >
    > I can find the *last* match in the column. However, if I can't find the
    > lookup value (e.g. 15) in Column A, "#N/A" will be shown and I would like

    to
    > assign the value "30" to it instead of showing "#N/A". However, if the

    lookup
    > value in column A (e.g. 12) can be found, the corresponding value in

    column B
    > (result of 24) is needed.
    >
    > So, How can I modify this formaula. And thank you all.
    >
    >
    >
    > "RagDyeR" wrote:
    >
    > > This *array* formula will give you the *last* match in the column:
    > >
    > > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    > >
    > > Array formulas are entered using CSE, <Ctrl> <Shift> <Enter>, instead of

    the
    > > regular <Enter>, which will *automatically* enclose the formula in curly
    > > brackets, which *cannot* be done manually.
    > >
    > > --
    > >
    > > HTH,
    > >
    > > RD
    > > ==============================================
    > > Please keep all correspondence within the Group, so all may benefit!
    > > ==============================================
    > >
    > >
    > > "L. Chung" <L. [email protected]> wrote in message
    > > news:[email protected]...
    > > There is a table as below:
    > >
    > > A B
    > > 1 11 20
    > > 2 12 21
    > > 3 12 22
    > > 4 13 23
    > > 5 12 24
    > >
    > > If I input the function "=vlookup(12,A1:B5,2,0)", the result would be

    "21"
    > > since Excel would find the first "12" (wich is in cell A2) in column A.
    > > However, when I would like to find the last "12" (which is in cell A5)

    in
    > > column A, that is the answer "24"(in cell B5) is required, how can I

    modify
    > > the function? Please help me.
    > >
    > >
    > >




  6. #6
    L. Chung
    Guest

    Re: VLOOKUP function

    I have tried the formula and it really the answer that I want.

    Thank you very much.

    "RagDyer" wrote:

    > Are we both talking about the same formula???
    >
    > The formula I suggested will *not* return a #N/A error if the lookup value
    > is not found in Column A.
    > It *will* return a #NUM! error though!
    >
    > Anyway, to eliminate the #NUM! error, you can try this *array* formula:
    >
    > =IF(ISNA(MATCH(12,A1:A15,0)),30,INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15))
    > ,1)))
    >
    > --
    > Array formulas must be entered with CSE, <Ctrl> <Shift > <Enter>, instead
    > oft the regular <Enter>, which will *automatically* enclose the formula in
    > curly brackets, which *cannot* be done manually.
    > --
    > HTH,
    >
    > RD
    > ==============================================
    > Please keep all correspondence within the Group, so all may benefit!
    > ==============================================
    >
    > "L. Chung" <L. [email protected]> wrote in message
    > news:[email protected]...
    > > There is another question and using same table again:
    > >
    > > A B
    > > 1 11 20
    > > 2 12 21
    > > 3 12 22
    > > 4 13 23
    > > 5 12 24
    > >
    > > By using below formula,
    > >
    > > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    > >
    > > I can find the *last* match in the column. However, if I can't find the
    > > lookup value (e.g. 15) in Column A, "#N/A" will be shown and I would like

    > to
    > > assign the value "30" to it instead of showing "#N/A". However, if the

    > lookup
    > > value in column A (e.g. 12) can be found, the corresponding value in

    > column B
    > > (result of 24) is needed.
    > >
    > > So, How can I modify this formaula. And thank you all.
    > >
    > >
    > >
    > > "RagDyeR" wrote:
    > >
    > > > This *array* formula will give you the *last* match in the column:
    > > >
    > > > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    > > >
    > > > Array formulas are entered using CSE, <Ctrl> <Shift> <Enter>, instead of

    > the
    > > > regular <Enter>, which will *automatically* enclose the formula in curly
    > > > brackets, which *cannot* be done manually.
    > > >
    > > > --
    > > >
    > > > HTH,
    > > >
    > > > RD
    > > > ==============================================
    > > > Please keep all correspondence within the Group, so all may benefit!
    > > > ==============================================
    > > >
    > > >
    > > > "L. Chung" <L. [email protected]> wrote in message
    > > > news:[email protected]...
    > > > There is a table as below:
    > > >
    > > > A B
    > > > 1 11 20
    > > > 2 12 21
    > > > 3 12 22
    > > > 4 13 23
    > > > 5 12 24
    > > >
    > > > If I input the function "=vlookup(12,A1:B5,2,0)", the result would be

    > "21"
    > > > since Excel would find the first "12" (wich is in cell A2) in column A.
    > > > However, when I would like to find the last "12" (which is in cell A5)

    > in
    > > > column A, that is the answer "24"(in cell B5) is required, how can I

    > modify
    > > > the function? Please help me.
    > > >
    > > >
    > > >

    >
    >
    >


  7. #7
    RagDyeR
    Guest

    Re: VLOOKUP function

    Appreciate the feed-back.
    --

    Regards,

    RD
    --------------------------------------------------------------------
    Please keep all correspondence within the Group, so all may benefit !
    --------------------------------------------------------------------

    "L. Chung" <[email protected]> wrote in message
    news:[email protected]...
    I have tried the formula and it really the answer that I want.

    Thank you very much.

    "RagDyer" wrote:

    > Are we both talking about the same formula???
    >
    > The formula I suggested will *not* return a #N/A error if the lookup value
    > is not found in Column A.
    > It *will* return a #NUM! error though!
    >
    > Anyway, to eliminate the #NUM! error, you can try this *array* formula:
    >
    >

    =IF(ISNA(MATCH(12,A1:A15,0)),30,INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15))
    > ,1)))
    >
    > --
    > Array formulas must be entered with CSE, <Ctrl> <Shift > <Enter>, instead
    > oft the regular <Enter>, which will *automatically* enclose the formula in
    > curly brackets, which *cannot* be done manually.
    > --
    > HTH,
    >
    > RD
    > ==============================================
    > Please keep all correspondence within the Group, so all may benefit!
    > ==============================================
    >
    > "L. Chung" <L. [email protected]> wrote in message
    > news:[email protected]...
    > > There is another question and using same table again:
    > >
    > > A B
    > > 1 11 20
    > > 2 12 21
    > > 3 12 22
    > > 4 13 23
    > > 5 12 24
    > >
    > > By using below formula,
    > >
    > > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    > >
    > > I can find the *last* match in the column. However, if I can't find the
    > > lookup value (e.g. 15) in Column A, "#N/A" will be shown and I would

    like
    > to
    > > assign the value "30" to it instead of showing "#N/A". However, if the

    > lookup
    > > value in column A (e.g. 12) can be found, the corresponding value in

    > column B
    > > (result of 24) is needed.
    > >
    > > So, How can I modify this formaula. And thank you all.
    > >
    > >
    > >
    > > "RagDyeR" wrote:
    > >
    > > > This *array* formula will give you the *last* match in the column:
    > > >
    > > > =INDEX(B1:B15,LARGE(IF(A1:A15=12,ROW(A1:A15)),1))
    > > >
    > > > Array formulas are entered using CSE, <Ctrl> <Shift> <Enter>, instead

    of
    > the
    > > > regular <Enter>, which will *automatically* enclose the formula in

    curly
    > > > brackets, which *cannot* be done manually.
    > > >
    > > > --
    > > >
    > > > HTH,
    > > >
    > > > RD
    > > > ==============================================
    > > > Please keep all correspondence within the Group, so all may benefit!
    > > > ==============================================
    > > >
    > > >
    > > > "L. Chung" <L. [email protected]> wrote in message
    > > > news:[email protected]...
    > > > There is a table as below:
    > > >
    > > > A B
    > > > 1 11 20
    > > > 2 12 21
    > > > 3 12 22
    > > > 4 13 23
    > > > 5 12 24
    > > >
    > > > If I input the function "=vlookup(12,A1:B5,2,0)", the result would be

    > "21"
    > > > since Excel would find the first "12" (wich is in cell A2) in column

    A.
    > > > However, when I would like to find the last "12" (which is in cell A5)

    > in
    > > > column A, that is the answer "24"(in cell B5) is required, how can I

    > modify
    > > > the function? Please help me.
    > > >
    > > >
    > > >

    >
    >
    >




+ 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