RE: retrieving top/bottom n rank()-ed data



Thanks for the quick reply, Ron. Well, sorry, perhaps I should have
clarified... my table actually contains more data than just those two, and I
need to pull out data from all columns for the top n and bottom n entries.

To illustrate, suppose column A stores the age of individuals and some
individuals happen to have the same age. Column B stores the ranking of the
age values. Then I also have column C storing name, D storing address, etc.,
etc.

I need to pull, say, the top n=10 individuals by age including their name,
address, etc., and also, say, the bottom m=10 individuals in the same way.
It's just that with =large() I can get the values but cannot use those values
to lookup the names, addresses, etc. because age is not unique. This is
essentially the same problem as using =rank().

The only way I can think of to achieve this is to do something like:

counter = 0
for i = 1 to n ' n as defined above
x =
application.countif(range(cells(row1st,LookupCol),cells(rowLast,LookupCol)),i)
if isnumeric(x) then
counter = counter + x
rowStart = row1st
for j = 1 to x
r = application.match(i,range(cells(rowStart,LookupCol), _
cells(rowLast,LookupCol)),0)
'
' then use r to lookup/copy everything I need
'
rowStart = r + 1
next j
end if
next i
' I recognize the above could potentially give me counter > n;
' I'll just need to tighten up the exit criteria
' for bottom m, i'll just have adjust the for/next variables

I'm just wondering if there is a simpler, more elegant way than the above to
achieve the same result.

Thanks.


"Ron Coderre" wrote:

Skip the RANK function and try this, instead:

With
A1:100
A2: 75
A3:100
A4: 75
A5: 50

And
C1: 1
C2: 2
C3: 3
C4: 4
C5: 5

Then
D1: =LARGE($A$1:$A$5,C1)
Copy D1 down through D5

In this example, the Col_D formula return
100
100
75
75
50

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"rockhammer" wrote:

I have a table in which one column (say A) contains unsorted numeric values
and another column (say B) contains the values returned by =rank() based on
those numeric values.

In cases where those numeric values in col A are not unique, the ranks in
column B will contain duplicates as well.

I want to find a way to extract the top ranking n numeric values and the
bottom ranking m numeric values WITHOUT HAVING TO SORT THE TABLE.

Is there an (easy) way to do that?

Thanks.

.



Relevant Pages

  • RE: retrieving top/bottom n rank()-ed data
    ... Hi Ron, thanks a lot for your efforts. ... The filtered cells are then copied and pasted at cell D1 ... 'Engage the autofilter ... suppose column A stores the age of individuals and some ...
    (microsoft.public.excel.programming)
  • Re: The Rewards of Performing
    ... Bottom fressers????? ... but the trolls have never done any better. ... >> groups that entertain people at churches,centers,old age homes,etc. ... >> maybe they think that the average opera workshop has the money to rent ...
    (rec.music.opera)
  • Re: Exporting mail rules from OE6
    ... could remember the darn question ... Wisdom and experience come with age, they say, but I wish I could ... Ron obviously knows something more about this than I do. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: My new EVIL TWINS Theory (was Re: A Thought About the Twins)
    ... but Hermione was also annoyed and I'm sure she got after him. ... Boy at that age are still Ick Girls. ... And I doubt Ginny was as excepting as Ron. ... paying attention to yell at them. ...
    (alt.fan.harry-potter)
  • Re: OT - On Taxes
    ... Ron Recer wrote: ... The Curmudgeon of Sill Hill ... If I had been putting my and my employer's "contribution" in a passbook savings account for the last forty+ years, it would be well over 1,000,000$ today and as I was born too late to collect anything at 62, I will have to wait until age 67 for full benefits. ... I am in the group who can draw full benefits at age 66 and I will be abe to draw about 75% of that at age 62. ...
    (rec.outdoors.rv-travel)

Loading