兩個6的排列組合數,用VBA如何實現?
各位先進你們好:想用VBA做一個有兩個6的排列組合數,像圖片這個做法,請問如何實現?謝謝!
[attach]34822[/attach] [b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118737&ptid=23646]1#[/url] [i]maiko[/i] [/b]
Sub test()
For i = 1 To 6
For j = 1 To 6
rr = rr + 1
Cells(rr, 1) = i
Cells(rr, 2) = j
Next j
Next i
End Sub 謝謝!解決了我的問題! [b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118737&ptid=23646]1#[/url] [i]maiko[/i] [/b]
Sub test()
Dim Arr(1 To 100000, 1 To 2), T&, i&, j&, n
Range("a1").CurrentRegion.ClearContents
T = InputBox("請輸入組合數字", "1,2,3...", "1")
For i = 1 To T: For j = 1 To T
n = n + 1: Arr(n, 1) = i: Arr(n, 2) = j
Next: Next
Range("a1").Resize(n, 2) = Arr
End Sub [url]https://blog.xuite.net/hcm19522/twblog/590367515[/url] [i=s] 本帖最後由 singo1232001 於 2022-5-3 15:04 編輯 [/i]
[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=118737&ptid=23646]1#[/url] [i]maiko[/i] [/b]
Sub abc()
y = 6
For i = 1 To y ^ 2 Step y
Cells(i, 1).Resize(6, 1) = i / 6 + 5 / 6 '<---公式在下方
Cells(i, 2).Resize(6, 1) = Application.Transpose(Array(1, 2, 3, 4, 5, 6))
Next
End Sub
發現規律
1列 =1
7列 =2
.......
設聯立方程式 代入y=ax+b
( 1=a+b
( 2=7a+b
-> a=1-b 代入 2=7a+b
-> 2=7(1-b)+b
-> -5=-6b
-> b=5/6 代入 1=a+b
-> a=1/6
獲得方程式 y=x/6+5/6
獲得程式碼 i/6+5/6
頁:
[1]