ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

±Æ¦C²Õ¦X

±Æ¦C²Õ¦X

½Ð°Ý¤j¯«­Ì ¦pªG1-39 ¨ú5ªº ±Æ¦C²Õ¦XÁ`¦@¦³ 575757 ²Õ
­n¦p¦ó¦bexcel ±Æ¦C¥X¨Ó
01 02 03 04 05
01 02 03 04 06
01 02 03 04 07

Ãþ¦ü³o¼Ë§â 575757²Õ ±Æ¥X¨Ó
³Â·Ð«e½ú«üÂI

¥»©«³Ì«á¥Ñ quickfixer ©ó 2020-2-22 08:57 ½s¿è

¦^´_ 3# n7822123

ÁÂÁ±оÇ,¥Î§A±Ðªº¤èªk
§ï¼g«e¶]3¤ÀÄÁ,§ï¼g«á6¬í¥ª¥k¶]§¹ ^^
Sub test2()
    Dim m As Integer, n As Integer, c As Double, t(1 To 39) As Integer, r As Double, arr()
    For i = 1 To 39: t(i) = i: Next i
    m = 39
    n = 5
    t0 = Timer
    c = Cmn(m) / (Cmn(m - n) * Cmn(n))
    ReDim arr(1 To c, 1 To n)
    Application.ScreenUpdating = False
    For i = 1 To m
        For j = i + 1 To m
            For k = j + 1 To m
                For l = k + 1 To m
                    For p = l + 1 To m
                        r = r + 1
                        arr(r, 1) = t(i)
                        arr(r, 2) = t(j)
                        arr(r, 3) = t(k)
                        arr(r, 4) = t(l)
                        arr(r, 5) = t(p)
                    Next p
                Next l
            Next k
        Next j
    Next i
    Range(Cells(1, 1), Cells(r, 5)) = arr()
    Application.ScreenUpdating = True
    MsgBox r & "²Õ¡G¨Ï¥Î®É¶¡" & Timer - t0 & "¬í"

End Sub

Function Cmn(x As Integer) As Double
    Dim i As Integer, y As Double
    y = 1
    For i = 1 To x
        y = y * i
    Next
    Cmn = y
End Function

TOP

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-2-22 00:32 ½s¿è

¦^´_ 1# eric7765


¤£­n¥ÎCellª«¥ó¡A¥Î¯Â¼Æ­È°}¦C¶]°j°é·|§Ö¤@ÂI
¤£¹L­n¤p¤ß°O¾ÐÅ餣¨¬


Sub test()
Const n = 39
ReDim T(n) As String
Dim C1%, C2%, C3%, C4%, C5%
Dim Arr(), Brr()
T0 = Timer
For i = 1 To n: T(i) = Format(i, "00"): Next
For C1 = 1 To n: For C2 = C1 + 1 To n: For C3 = C2 + 1 To n
For C4 = C3 + 1 To n: For C5 = C4 + 1 To n
    k = k + 1: ReDim Preserve Arr(1 To 1, 1 To k)
    Arr(1, k) = T(C1) & " " & T(C2) & " " & T(C3) & " " & T(C4) & " " & T(C5)
Next: Next: Next: Next: Next
'[A1].Resize(UBound(Arr, 2), 1) = Application.Transpose(Arr)  '°}¦C¤Ó¤j·|²£¥Í¿ù»~......
'Äd-¦C¥æ´«(¦Û¤v¤â°Ê¼g)
ReDim Brr(1 To UBound(Arr, 2), 1 To 1)
For i = 1 To UBound(Arr, 2): Brr(i, 1) = Arr(1, i): Next
[A1].Resize(UBound(Brr)) = Brr: Columns.AutoFit
MsgBox "¤w¦C¥X" & UBound(Brr) & "²Õ¡A" & "¦@¨Ï¥Î®É¶¡" & Round(Timer - T0, 2) & "¬í"
Erase Arr: Erase Brr
End Sub
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¦^´_ 1# eric7765

a1~a39, ¶ñ¤J1~39,µM«á­@¤ßµ¥= =
Sub test()
Dim n As Variant, c As Double
n = Application.Transpose(Range("A1", Range("A1").End(xlDown)))
Application.ScreenUpdating = False
For i = 1 To UBound(n)
    For j = i + 1 To UBound(n)
        For k = j + 1 To UBound(n)
            For l = k + 1 To UBound(n)
                For m = l + 1 To UBound(n)
                 c = c + 1
                 Cells(c, 2) = n(i)
                 Cells(c, 3) = n(j)
                 Cells(c, 4) = n(k)
                 Cells(c, 5) = n(l)
                 Cells(c, 6) = n(m)
                Next m
            Next l
        Next k
    Next j
Next i
Application.ScreenUpdating = True
MsgBox c & "²Õ"
End Sub

TOP

        ÀR«ä¦Û¦b : ®É®É¦n¤ß´N¬O®É®É¦n¤é¡C
ªð¦^¦Cªí ¤W¤@¥DÃD