Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

five highest, five lowest 2

Status
Not open for further replies.

eHanSolo

Technical User
May 24, 2004
260
GB
hi all,

if i have a list of random numbers, both negative and positive. how can obtain the highest 5 and lowest five and paste it on a different sheet without having to manually sort it first?

using max or min would only get me two values.

maybe some vba is needed here?

any help would be good.

thanks.

e
 
only thing i can think of is a bubble sort on a array.
might be less code if you bubble sort on an array with 6 elements and then bin off the last element.

you can avoid bubble sorting for every random number by checking your number against the last element in the array, if it is higher then go through the 6 elemennt bubble sort thang.

 
Have a look at the LARGE and SMALL worksheet functions, which will allow you to select the kth largest and kth smallest value in an array or range, respectively.


Regards,
Mike
 
Look at the LARGE and SMALL functions.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
fantastic... works a treat!!!

*bear hugs all of them*

thank you again!


Best,

e
 
9.5 out of 10 on the synchronized typing, and taught me something to boot. Stars for both.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top