Sub RankSt() Dim i As Integer, j As Integer Dim B(1 To 18) As String Dim TEMP As String
Application.ScreenUpdating = False '关闭屏幕更新,加快代码运行 For i = 1 To 18 B(i) = Sheet1.Cells(i + 1, 1) Next For i = 1 To 17 For j = i + 1 To 18 If B(i) < B(j) Then TEMP = B(j) B(j) = B(i) B(i) = TEMP End If Next j Next i 'For i = 1 To 18 ' Sheet1.Cells(i + 1, 3) = "'" & B(i) 'Next i Sheet1.Range("c2:c19").NumberFormatLocal = "@" '设置单元格为文本格式 Sheet1.Range("c2:c19") = Application.WorksheetFunction.Transpose(B) '把行数组转换成列数组,一次赋值 End Sub |