Sub yy()
Dim arr, a, b, i, j, k, m, n, y
arr = [a1].CurrentRegion
y = UBound(arr)
[p1].Resize(y, 2) = arr
[p2].Resize(y - 1, 2).Sort [q2], 1
arr = [p1].CurrentRegion
[p1].CurrentRegion = ""
a = 600
b = 650
ReDim brr(1 To y, 1 To 6)
For i = y To 3 Step -1
For j = 2 To y
If arr(i, 2) + arr(j, 2) >= a And arr(i, 2) + arr(j, 2) <= b Then
m = m + 1
brr(m, 1) = m
brr(m, 2) = arr(i, 1)
brr(m, 3) = arr(i, 2)
brr(m, 4) = arr(j, 1)
brr(m, 5) = arr(j, 2)
brr(m, 6) = brr(m, 3) + brr(m, 5)
arr(i, 2) = 0
arr(j, 2) = 0
End If
Next
Next
For i = 2 To y
If arr(i, 2) <> 0 Then
n = n + 1
arr(n, 1) = arr(i, 1)
arr(n, 2) = arr(i, 2)
End If
Next
[f3:n100] = ""
[F3].Resize(m, 6) = brr
[m3].Resize(n, 2) = arr
End Sub |