调用代码,因为组合排列运行较慢,红色地方你手动去调比较好
Dim t As Table = Tables("Sheet1")
Dim a(t.rows.Count-1) As String
For i As Integer = 0 To t.rows.Count - 1
a(i) = i
Next
Dim b(t.rows.Count) As String
For i As Integer = 6 To 6 ' = 1 to t.rows.Count
Functions.Execute("loop", a, t.rows.Count, i, b, i)
Next
msgbox("查询完毕")
-----------------------------------------
内部函数 loop
Dim a() As String = args(0)
Dim n As Integer = args(1)
Dim m As Integer = args(2)
Dim b() As String = args(3)
Dim Mm As Integer = args(4)
For i As Integer = n To m Step -1
b(m-1) = i-1
If m > 1 Then
Functions.Execute("loop", a, i-1, m-1, b, Mm)
Else
Dim sum1 As Double = 0
Dim sum2 As Double = 0
Dim t As Table = Tables("Sheet1")
For j As Integer = 0 To Mm - 1
sum1 += t.rows(a(b(j)))("第一列")
sum2 += t.rows(a(b(j)))("第二列")
Next
If sum1 = 1645 AndAlso sum2 >= 14 AndAlso sum2 <= 15 Then
Dim result As String = ""
For j As Integer = 0 To Mm - 1
result &= a(b(j))+1 & ","
Next
output.show("找到,行(" & result.Trim(",") & "),第二列和:(" & sum2 & ")" )
End If
End If
Next