當前位置:成語大全網 - 新華字典 - 用VBA給同學成績分等級,拍名次

用VBA給同學成績分等級,拍名次

Sub Grade()

For i = 2 To Cells(Rows.Count, 1).End(3).Row

x = Cells(i, 2)

Select Case x

Case Is < 60

Cells(i, 3) = "F"

Cells(i, 4) = WorksheetFunction.Rank(Cells(i, 2), Range(Cells(2, 2), Cells(Cells(Rows.Count, 1).End(3).Row, 2)))

Case Is < 70

Cells(i, 3) = "D"

Cells(i, 4) = WorksheetFunction.Rank(Cells(i, 2), Range(Cells(2, 2), Cells(Cells(Rows.Count, 1).End(3).Row, 2)))

Case Is < 80

Cells(i, 3) = "C"

Cells(i, 4) = WorksheetFunction.Rank(Cells(i, 2), Range(Cells(2, 2), Cells(Cells(Rows.Count, 1).End(3).Row, 2)))

Case Is < 90

Cells(i, 3) = "B"

Cells(i, 4) = WorksheetFunction.Rank(Cells(i, 2), Range(Cells(2, 2), Cells(Cells(Rows.Count, 1).End(3).Row, 2)))

Case Else

Cells(i, 3) = "A"

Cells(i, 4) = WorksheetFunction.Rank(Cells(i, 2), Range(Cells(2, 2), Cells(Cells(Rows.Count, 1).End(3).Row, 2)))

End Select

Next

End Sub