- Sub try()
- Dim arr, i, j, k, m, n, t
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- arr = Range("c4:h8").Value
- For i = 1 To UBound(arr)
- For j = 1 To UBound(arr, 2) - 1
- For k = j + 1 To UBound(arr, 2)
- d(arr(i, j) & "," & arr(i, k)) = d(arr(i, j) & "," & arr(i, k)) + 1
- Next k
- Next j
- For j = 1 To UBound(arr, 2) - 2
- For k = j + 1 To UBound(arr, 2) - 1
- For m = k + 1 To UBound(arr, 2)
- d(arr(i, j) & "," & arr(i, k) & "," & arr(i, m)) = d(arr(i, j) & "," & arr(i, k) & "," & arr(i, m)) + 1
- Next m
- Next k
- Next j
- For j = 1 To UBound(arr, 2) - 3
- For k = j + 1 To UBound(arr, 2) - 3
- For m = k + 1 To UBound(arr, 2) - 1
- For n = m + 1 To UBound(arr, 2)
- d(arr(i, j) & "," & arr(i, k) & "," & arr(i, m) & "," & arr(i, n)) = d(arr(i, j) & "," & arr(i, k) & "," & arr(i, m) & "," & arr(i, n)) + 1
- Next n
- Next m
- Next k
- Next j
- Next i
- t = d.items
- mx = WorksheetFunction.Max(t)
- For X = 1 To 3 '几个号码组合
- s = ""
- For i = mx To 1 Step -1
- For Each k In d
- If Len(k) = Len(Replace(k, ",", "")) + X And d(k) = i Then
- s = s & "|" & k
- End If
- Next k
- If s <> "" Then
- [l8].Offset(X - 1) = Mid(s, 2)
- [m8].Offset(X - 1) = i
- Exit For
- End If
- Next i
- Next X
- End Sub
复制代码 |