|
本帖最后由 roych 于 2012-8-21 21:49 编辑
俺觉得你把问题复杂化了,先附上代码(写入Sheet1里):- Sub test()
- Dim s(1 To 6), P(1 To 4)
- Dim i, j, k, l
- '分解组合第一个数组
- For i = 1 To 6
- s(i) = Range("B5").Offset(0, i - 1)
- Next
- For i = 1 To 6
- For j = i + 1 To 6
- For k = j + 1 To 6
- a = a & "," & s(i) & ":" & s(j) & ":" & s(k)
- Next
- Next
- Next
- c = Split(a, ",")
- '分解组合第二个数组
- For i = 1 To 4
- P(i) = Range("L5").Offset(0, i - 1)
- Next
- For i = 1 To 4
- For j = i + 1 To 4
- For k = j + 1 To 4
- b = b & "," & P(i) & ":" & P(j) & ":" & P(k)
- Next
- Next
- Next
- d = Split(b, ",")
- '合并两个组合
- For i = 1 To UBound(d)
- For j = 1 To UBound(c)
- e = e & "," & c(j) & ":" & d(i)
- Next
- Next
- f = Split(e, ",")
- '写入数据
- For i = 1 To UBound(f)
- Range("w" & i + 1) = f(i)
- Next
- End Sub
复制代码 当然,代码可以更简化些许,不过个人觉得这样写的好处在于可以让大家理清思路。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|