#1   Report Post  
L. Chung
 
Posts: n/a
Default 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   Report Post  
DReims
 
Posts: n/a
Default

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   Report Post  
RagDyeR
 
Posts: n/a
Default

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. wrote in message
...
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   Report Post  
L. Chung
 
Posts: n/a
Default

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. wrote in message
...
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   Report Post  
RagDyer
 
Posts: n/a
Default

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. wrote in message
...
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.
wrote in message
...
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   Report Post  
L. Chung
 
Posts: n/a
Default

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. wrote in message
...
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.
wrote in message
...
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   Report Post  
RagDyeR
 
Posts: n/a
Default

Appreciate the feed-back.
--

Regards,

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

"L. Chung" wrote in message
...
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. wrote in message
...
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.
wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-sequential VLOOKUP function -OR- sequential sort of web query Eric S Excel Worksheet Functions 1 February 28th 05 07:50 PM
I want to use Vlookup function and AND function in a single formu. prakash Excel Worksheet Functions 3 January 25th 05 07:11 AM
carrying a hyper link when using the vlookup function mike Excel Worksheet Functions 1 November 19th 04 03:49 AM
carrying a hyper link when using the vlookup function mike Excel Worksheet Functions 2 November 18th 04 04:22 PM
Regarding IF function or vLOOKUP function wuwu Excel Worksheet Functions 2 November 13th 04 01:38 PM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"