Consulting

Results 1 to 9 of 9

Thread: Two rankings

  1. #1

    Two rankings

    RANKING.xlsx
    May I ask the teacher on the forum,how to deal with the ranking of grades,about class ranking and the total ranking?

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    I am very grateful for your answer.
    If I want to write VBA CODE about ranking, hope someone can teach me!

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I would use the macro recorder for this; giving you a solution will not "teach you"
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    I mean that I was hoping someone could teach me how to use VBA to solve the problem instead of using "FORMULA".

  6. #6
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    range("d2:d10").formula="=rank(........)"
    range("e2:e10").formula="=sumproduct(.........)"

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I wouldn't try to reinvent the wheel.
    1. Write the formula while recording a macro
    2. Adjust the macro to put the formula in required cells
    3. Copy/Paste special the results
    If you have problems, post your code.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    It's not that simple:

    Sub M_snb()
       [D2:D10] = [index(rank(C2:C10,C2:C10),)]
       
       For j = 1 To 4
          [G1] = j
          [G2:G10] = [if(A2:A10=G1,C2:C10,"")]
          [E2:E10] = [if(E2:E10="",if(G2:G10="","",rank(G2:G10,G2:G10)),E2:E10)]
        Next
       
       [G1:G10].ClearContents
    End Sub

  9. #9
    Thanks to including mdmackillop, mana, snb, whether it is teaching or to provide solution, because the work just encountered such a ranking problem, for a long time can not be resolved, so I hope to learn some vba skills, if there are impolite, please forgive me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •