You are on page 1of 1

Sub sorting()

For L = 6 To 912 Step 2


L2 = L + 1

Range("D" & L & ":J" & L2).Select


Selection.Sort Key1:=Range("D" & L2), Order1:=xlDescending, Header:=xlGuess,
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight,
DataOption1:=xlSortNormal

T = WorksheetFunction.Sum(Range(Cells(L2, 4), Cells(L2, 10)))

For I = 4 To 10
ST = WorksheetFunction.Sum(Range(Cells(L2, 4), Cells(L2, I)))

P = ST / T

If P >= 0.8 Then


If I = 4 Then
M = WorksheetFunction.Max(Range(Cells(L, 4), Cells(L, I)))
Else
M = WorksheetFunction.Max(Range(Cells(L, 4), Cells(L, I - 1)))
End If

CMJ = M / 26

Range("L" & L2).Value = CMJ


Exit For
End If
Next I

Next L
End Sub

You might also like