+ Reply to Thread
Results 1 to 9 of 9

Find Toppers of each unique code in a column

  1. #1
    Registered User
    Join Date
    04-15-2008
    Location
    Tamil Nadu, India.
    MS-Off Ver
    Microsoft Office 2016
    Posts
    580

    Thumbs up Find Toppers of each unique code in a column

    Dear Friends,

    I have some 8000 rows of data consists of a survey.

    I need to find out TOPPERS of each SUB_CODE which are available in a single column.

    I have clearly mentioned the problem and the solution required in the attached workbook.

    I hope someone will help me to solve this.

    Thanks in advance,

    acsishere.
    Attached Files Attached Files
    Last edited by acsishere; 05-12-2009 at 03:37 PM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Find Toppers of each unique code in a column

    Try this macro

    It sorts data in column A to G
    extracts toppers to column K to Q
    Resorts column A to G back to original sort

    Code will not work correctly if each Sub Code does not have at least 2 Sub Cat categorys - Do they all have more than 1?


    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    04-15-2008
    Location
    Tamil Nadu, India.
    MS-Off Ver
    Microsoft Office 2016
    Posts
    580

    Smile Re: Find Toppers of each unique code in a column

    Thanks for the code.

    But, when I checked with the sample data, it finds 2 toppers in each code. Whereas, In my data some codes may have only one topper, or some codes may have 2 toppers, or some other codes may have three or more.

    The above code finds only two toppers of each code.

    Besides, I don't want to sort the data. Without sorting is it possible?

    Once again I have attached the worksheet along with the above code tested in it (in SHEET4). I have explained the difficulty also in it.

    Thanks in advance.

    Yours, acsishere.
    Attached Files Attached Files
    Last edited by acsishere; 05-10-2009 at 01:30 PM. Reason: I thought to edit some data in the attachment.

  4. #4
    Registered User
    Join Date
    04-15-2008
    Location
    Tamil Nadu, India.
    MS-Off Ver
    Microsoft Office 2016
    Posts
    580

    Re: Find Toppers of each unique code in a column

    Dear Friends,

    Any help? Please.

    Thanks in advance, acsishere.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Toppers of each unique code in a column

    You might want to specify exactly what a Topper is? What determines what makes it as a Topper and what does not?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Find Toppers of each unique code in a column

    I think I understand what ou want this time

    I originally thought you want the top points listed by Sub Code & Sub Cat, not just the top points by Sub Code


    I sort the data because it is the easiest way to pickup the highest and multiple equal points per Sub Code.
    The data is restored to its un sorted state before the macro was run


    Please Login or Register  to view this content.
    If the use of the sort is causing a problem please explain what problem it is causing
    Last edited by mudraker; 05-11-2009 at 08:47 AM.

  7. #7
    Registered User
    Join Date
    04-15-2008
    Location
    Tamil Nadu, India.
    MS-Off Ver
    Microsoft Office 2016
    Posts
    580

    Smile Re: Find Toppers of each unique code in a column

    Dear Sir,

    Thanks a lot for your code. It exactly solves the purpose.

    In my workbook, data is split for some reason. i.e. The entire data consists of around 8000 records. For some reason the data is differenciated with some 200 rows gap (i.e. 800 records, then 200 rows gap, again 800 records, then 200 rows gap, and so on...)

    That's why I said that the sorting may give some trouble to original data source.

    Otherwise, your code is working nicely.

    Is there any possibility to get the result without sorting?

    Thanks in advance,

    acsishere.

  8. #8
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Find Toppers of each unique code in a column

    It is possible to get them without sorting, but it would take a lot more coding as the macro would need to keep track of the top scores for each Sub_Code and compare them to each entry on the spread sheet

    Using Sort is much quicker & easier & blank cells can taken into account



    I have added a command to ignore any row that does not have an entry in column D

    I inserted some blank rows into your posted example workbook and the code
    worked ok.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-15-2008
    Location
    Tamil Nadu, India.
    MS-Off Ver
    Microsoft Office 2016
    Posts
    580

    Re: Find Toppers of each unique code in a column

    Respected Sir,

    You just cracked it. Thanks a lot for the modifications & continuous effort.

    sincerely yours,
    acsishere.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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