Sub 按钮1_Click()
Dim wb As Workbook
Dim sht As Worksheet, sht1 As Worksheet
Dim arr
Dim dic As Object
Application.ScreenUpdating = False
Set sht1 = ThisWorkbook.Sheets("排五遗漏数据")
For j = 3 To 15 Step 3
sht1.Range(sht1.Cells(2, j - 1), sht1.Cells(11, j)).ClearContents
Next
Set wb = Workbooks.Open(ThisWorkbook.path & "\排五.xlsx")
Set sht = wb.Sheets(1)
arr = sht.Range("a1").CurrentRegion
wb.Close False
c = 3
For j = 2 To 6
For k = 0 To 9
For i = UBound(arr) To LBound(arr) + 1 Step -1
If arr(i, j) * 1 = k Then
sht1.Cells(k + 2, c) = UBound(arr) - i
sht1.Cells(k + 2, c - 1) = k
Exit For
End If
Next
Next
c = c + 3
Next
For j = 2 To 14 Step 3
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:=Range(Cells(2, j + 1), Cells(11, j + 1)), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Range(Cells(1, j), Cells(11, j + 1))
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next
Application.ScreenUpdating = True
End Sub
下载源码链接:(https://download.csdn.net/download/weixin_43050480/87211884)
PS:亲自测10期可以中2期,最多的时候中4期