|
楼主 |
发表于 2020-3-21 11:20
|
显示全部楼层
Sub zhgg()
arr = Range("A5", [b5].End(4))
bz = [b2]
ReDim scrr(1 To 10 ^ 5, 1 To 2)
brr = scrr
m = UBound(arr)
For a = 1 To m
For B = a To m
hj = arr(a, 2) - arr(B, 2)
If hj >= 0 Then
i = i + 1
brr(i, 1) = arr(a, 1) & " - " & arr(B, 1)
brr(i, 2) = hj
End If
Next B, a
crr = YjhSort10(brr, 1, 2, 1, i)
scbz = False
For ii = 1 To i - 1
If brr(crr(0)(ii + 1), 2) - brr(crr(0)(ii), 2) < bz Then
If Not scbz Then
sci = sci + 1
scrr(sci, 1) = brr(crr(0)(ii), 1)
scrr(sci, 2) = brr(crr(0)(ii), 2)
scbz = True
End If
sci = sci + 1
scrr(sci, 1) = brr(crr(0)(ii + 1), 1)
scrr(sci, 2) = brr(crr(0)(ii + 1), 2)
Else
If scbz Then sci = sci + 1: scbz = False
End If
Next
Range("m5").Resize(sci, 2) = scrr
End Sub |
|