Finding the top n elements in a range

pkd

New Member
Joined
Nov 3, 2011
Messages
2
Hi,

I need to find top/bottom N elements in a range. I have created an array out of the range. I am not sure how to find the top/bottom elements? LARGE function would give me the actual value, however I am interested in finding the indexes. Please help
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Gerald Higgins

Well-known Member
Joined
Mar 26, 2007
Messages
9,115
Hi, welcome to the board.

Why not try the INDEX and LARGE functions together, possibly with the assistance of the MATCH function ?
 

pkd

New Member
Joined
Nov 3, 2011
Messages
2
Can you provide an example?

Lets say I have a range A1:A100, and I have created an array out of it. My array is integerArray(1 to 100, 1 to 1). Now, I need to find the top 3 elements in this array, and their indexes. Where do I go from here (without doing a for loop)?
 

Gerald Higgins

Well-known Member
Joined
Mar 26, 2007
Messages
9,115
So long as all your values are unique . . .
Code:
=LARGE(A1:A100,3)
will return the 3rd largest value.

And this
Code:
=match(large(a1:a100,3),a1:a100,0)
will return its position in the array.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,499
Messages
5,596,515
Members
414,074
Latest member
Matthew Kakde

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top