现有一批五位数的组合例:1 2 3 4 5 ;2 3 4 5 6;6 7 8 9 10.。。。。。这样的组合有一大批,现在要将这些组合进行五选四的工作即例:1 2 3 4 5进行组合的到结果1 2 3 4 ;1 2 3 5 ; 1 2 4 5 ;1 3 4 5 ;2 3 4 5的样式。能一次性把所有的五位数组合变成四位数组合。。可否用vba实现??求大神帮助
Sub Combine() sd = Array(1, 2, 3, 4, 5) CurrentRow = 1 For a1 = 0 To 4 For a2 = 0 To 4 If a2 > a1 Then For a3 = 0 To 4 If a3 > a2 And a3 > a1 Then For a4 = 0 To 4 If a4 > a3 And a4 > a2 And a4 > a1 Then Cells(CurrentRow, 1) = sd(a1) & sd(a2) & sd(a3) & sd(a4) CurrentRow = CurrentRow + 1 End If Next End If Next End If Next NextEnd Sub这个代码只能实现一组,要完成工作的话要一次一次输入。工作量太大
Sub Combine() sd = Array(1, 2, 3, 4, 5) CurrentRow = 1 For a1 = 0 To 4 For a2 = 0 To 4 If a2 > a1 Then For a3 = 0 To 4 If a3 > a2 And a3 > a1 Then For a4 = 0 To 4 If a4 > a3 And a4 > a2 And a4 > a1 Then Cells(CurrentRow, 1) = sd(a1) & sd(a2) & sd(a3) & sd(a4) CurrentRow = CurrentRow + 1 End If Next End If Next End If Next NextEnd Sub这个代码只能实现一组,要完成工作的话要一次一次输入。工作量太大

