|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 3190496160 于 2022-10-26 18:23 编辑
Sub 前20名()
Application.ScreenUpdating = False
Dim ar As Variant, cr As Variant
Dim i As Long, r As Long, rs As Long
Dim br()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("成绩总表")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "成绩总表为空,请先导入数据!": End
ar = .Range(.Cells(1, 1), .Cells(r, "ap"))
End With
ReDim br_物(1 To UBound(ar), 1 To UBound(ar, 2))
ReDim br_历(1 To UBound(ar), 1 To UBound(ar, 2))
zd_进 = Application.Large(Application.Index(ar, 0, 41), 20)
ReDim brr_进(1 To UBound(ar), 1 To 4)
For i = 2 To UBound(ar)
If Trim(ar(i, 5)) = "物" Then
n = n + 1
For j = 1 To UBound(ar, 2)
br_物(n, j) = ar(i, j)
Next j
ElseIf Trim(ar(i, 5)) = "历" Then
nn = nn + 1
For j = 1 To UBound(ar, 2)
br_历(nn, j) = ar(i, j)
Next j
End If
If Trim(ar(i, 41)) <> "" Then
If IsNumeric(ar(i, 41)) Then
If ar(i, 41) >= zd_进 Then
s = s + 1
brr_进(s, 1) = ar(i, 2)
brr_进(s, 2) = ar(i, 3)
brr_进(s, 3) = ar(i, 37)
brr_进(s, 4) = ar(i, 41)
End If
End If
End If
Next i
zd_物 = Application.Large(Application.Index(br_物, 0, 37), 20)
ReDim brr_物(1 To n, 1 To 4)
For i = 1 To n
If Trim(br_物(i, 37)) <> "" Then
If IsNumeric(br_物(i, 37)) Then
If br_物(i, 37) >= zd_物 Then
m = m + 1
brr_物(m, 1) = br_物(i, 39)
brr_物(m, 2) = br_物(i, 3)
brr_物(m, 3) = br_物(i, 2)
brr_物(m, 4) = br_物(i, 37)
End If
End If
End If
Next i
zd_历 = Application.Large(Application.Index(br_历, 0, 37), 20)
ReDim brr_历(1 To n, 1 To 4)
For i = 1 To nn
If Trim(br_历(i, 37)) <> "" Then
If IsNumeric(br_历(i, 37)) Then
If br_历(i, 37) >= zd_历 Then
mm = mm + 1
brr_历(mm, 1) = br_历(i, 39)
brr_历(mm, 2) = br_历(i, 3)
brr_历(mm, 3) = br_历(i, 2)
brr_历(mm, 4) = br_历(i, 37)
End If
End If
End If
Next i
With Sheets("前20名")
.[a1].CurrentRegion.Offset(2) = Empty
.[a3].Resize(m, 4) = brr_物
.[e3].Resize(mm, 4) = brr_历
.[i3].Resize(s, 4) = brr_进
End With
Application.ScreenUpdating = True
MsgBox zd
End Sub
|
|