Ranking with multiple column

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
884
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team

I have almost 50 tab data and I want to rank columns F, E, D, C, B high to low (if we have duplicate data in each F column or pre.)
so can we have a MACRO for this Each tab name Q6a,Q6b till Q6e , then Q7a,Q7b. till Q7e

let me know if you have any questions

Ranked Data.xlsx
ABCDEF
3Q2 2020Q3 2020Q4 2020Q1 2021Q2 2021
4
5Fidelity119111110
6Charles Schwab65555
7Voya (F)23222
8Prudential11111
9Ameriprise00111
10TIAA00111
11T Rowe Price10010
12John Hancock00000
13Lincoln Financial00000
14The Hartford00000
15Principal Financial Group00000
16Empower Retirement00000
17Transamerica00000
18Competitor Average11111
1



Thanks
Sanjeev
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Sanjeev,

It sounds like you want to perform a custom sort along the lines of...
  1. Column F High to Low
  2. Column E High to Low
  3. Column D High to Low
  4. Column C High to Low
  5. Column B High to Low
... and apply that sort to all 50 worksheets in your workbook at the same time. Is that correct? Or the other way I think you may want is to...

  1. Figure out which row in each worksheet is the best based upon the sum or average of all the values between Column B to Column F
  2. Sort Each worksheet based upon that rank
Is that correct?

Either way, here are two solutions that you may wish to use:

VBA Code:
Sub SortRowsFtoB()

    For Each Sheet In Application.ThisWorkbook.Worksheets
        With Sheet
            'This IF only needed b/c I have two diff sets and solutions in the workbook.
            If .Name = "Sheet1" Or .Name = "Sheet2" Or .Name = "Sheet3" Then
                .Sort.SortFields.Clear
                
                .Sort.SortFields.Add2 Key:=Range("F:F") _
            , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
                
                .Sort.SortFields.Add2 Key:=Range("E:E") _
            , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
            
            .Sort.SortFields.Add2 Key:=Range("D:D") _
            , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
            
            .Sort.SortFields.Add2 Key:=Range("C:C") _
            , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
            
            .Sort.SortFields.Add2 Key:=Range("B:B") _
            , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
            
            With .Sort
                .SetRange Range("A:F")
                .Header = xlYes
                .MatchCase = False
                .Orientation = xlTopToBottom
                .SortMethod = xlPinYin
                .Apply
            End With
        End If
    End With
    Next Sheet
End Sub

Sub SortRowsOnAVG()
    For Each Sheet In Application.ThisWorkbook.Worksheets
        With Sheet
            If .Name = "Sheet4" Or .Name = "Sheet5" Or .Name = "Sheet6" Then
                .Sort.SortFields.Clear
                
                .Sort.SortFields.Add2 Key:=Range("G:G") _
            , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
                                
            
            With .Sort
                .SetRange Range("A:G")
                .Header = xlYes
                .MatchCase = False
                .Orientation = xlTopToBottom
                .SortMethod = xlPinYin
                .Apply
            End With
        End If
    End With
    Next Sheet
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,790
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top