|
发表于 2013-3-19 16:38
|
显示全部楼层
本楼为最佳答案
- Private Sub 组合_Click()
- Dim Arr, i&, r%, s(), j&, i1&, i2&, i3&, i4&, i5&, x$, x3%
- Dim d, k, Brr
- Range("a4:ce14") = ""
- Set d = CreateObject("Scripting.Dictionary")
- For x3 = 0 To 3
- Arr = Range(Cells(1, 1 + x3 * 14), Cells(2, 7 + x3 * 14))
- Debug.Print Range(Cells(1, 1 + x3 * 14), Cells(2, 7 + x3 * 14)).Address(False, False)
- For i = 1 To UBound(Arr)
- For j = 1 To UBound(Arr, 2)
- If Arr(i, j) <> "" Then
- r = r + 1
- ReDim Preserve s(1 To r)
- s(r) = Arr(i, j)
- End If
- Next
- If r >= 5 Then
- For i1 = 1 To r - 4
- For i2 = i1 + 1 To r - 3
- For i3 = i2 + 1 To r - 2
- For i4 = i3 + 1 To r - 1
- For i5 = i4 + 1 To r
- x = s(i1) & "," & s(i2) & "," & s(i3) & "," & s(i4) & "," & s(i5)
- d(x) = ""
- Next
- Next
- Next
- Next
- Next
- End If
- r = 0
- Next
- k = d.keys
- ReDim Brr(1 To d.Count, 1 To 7)
- For i = 0 To UBound(k)
- aa = Split(k(i), ",")
- For j = 0 To UBound(aa)
- Brr(i + 1, aa(j)) = aa(j)
- Next
- Next
- Cells(4, 1 + x3 * 14).Resize(UBound(Brr), 7) = Brr
- d.RemoveAll
- Next x3
- End Sub
复制代码 |
|