+ Reply to Thread
Results 1 to 5 of 5

Select the highest/lowest n values from a sorted column

  1. #1
    Registered User
    Join Date
    05-25-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    3

    Post Select the highest/lowest n values from a sorted column

    have a table with 12 columns (A:J) with the 11th column containing the user score and the 12th column containing the user rank. I have created a separate sub to sort the data as necessary. I am attempting to create a new sub to run after the sorting sub that would select the highest or lowest n (e.g. 3) values and then paste the associated rows in a separate sheet in the same workbook.

    A sample of the dataset can be seen here:
    FPGlE.png

    I'm a newbie in VBA and programming. Any help would be appreciated.

    The attempted VBA code (DID NOT WORK) has been added below


    Please Login or Register  to view this content.
    Last edited by ShannayR; 05-25-2020 at 11:16 AM. Reason: Clarification

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    606

    Re: Select the highest/lowest n values from a sorted column

    I'm sorry if I'm not helping here.
    Just want to understand what did you mean by this :

    Quote Originally Posted by ShannayR View Post
    I am attempting to create a new sub to run after the sorting sub that would
    select the highest and lowest n (e.g. 3) values
    Because from the image you post,
    I thought the highest score is 24 and the lowest score is 5 ?

  3. #3
    Registered User
    Join Date
    05-25-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    3

    Re: Select the highest/lowest n values from a sorted column

    Quote Originally Posted by karmapala View Post
    I thought the highest score is 24 and the lowest score is 5 ?
    I want to select the 3 highest scores (24, 18, 14) from the dataset.
    I cannot fix the 3 values as I am looking for a more inclusive way of carrying out the operation that can be used in a variety of uses.
    Defining
    lNumTopEntries
    was to incorporate this flexibility.

  4. #4
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,205

    Re: Select the highest/lowest n values from a sorted column

    Since it has already been sorted the top and the bottom values are at the edge of the range.
    If your data from the OP is on Sheet1.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    05-25-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    3

    Re: Select the highest/lowest n values from a sorted column

    Quote Originally Posted by mikerickson View Post
    Since it has already been sorted the top and the bottom values are at the edge of the range.
    That worked out fairly well, but how do I select recurring values? In the posted data, selecting the top 3 values should get the sub to select sample3:sample9.
    The code only selects the first 3 rows without checking if the values are repeating.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro for creating a pivot table sorted with highest to Lowest chargeable Weight
    By ADITHYA1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2018, 02:24 AM
  2. [SOLVED] Re: Find lowest 5 numbers in column A with highest values in column B
    By jd16 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-05-2013, 02:08 AM
  3. Replies: 4
    Last Post: 10-06-2013, 10:40 AM
  4. Find lowest 5 numbers in column A with highest values in column B
    By dmccoy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2013, 09:22 AM
  5. Replies: 4
    Last Post: 07-06-2013, 04:44 PM
  6. [SOLVED] Formula to select the highest number, and the lowest and find out the range
    By Nero_slk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-14-2013, 07:56 AM
  7. Replies: 6
    Last Post: 01-11-2012, 12:06 PM

Tags for this Thread

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