|
代码如下。。。
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$D$1" Then
arr = [b11:b140]
ReDim crr(1 To UBound(arr), 1 To 1)
For i = 1 To UBound(arr)
If arr(i, 1) > 0 Then arr(i, 1) = 1 Else arr(i, 1) = 0
s = s & CStr(arr(i, 1))
crr(i, 1) = 0
Next
ReDim brr(1 To UBound(arr), 1 To 2)
For i = 1 To UBound(arr)
If arr(i, 1) > 0 Then
x = InStr(i, s, "000")
y = InStr(i, s, "100")
Z = InStr(i, s, "0100")
zz = InStr(i, s, "0010")
m = Application.Min(Z, zz)
If i = y Then
i = i + 2
Else
If x <= m And x > 0 Then
n = n + 1
brr(n, 1) = i
brr(n, 2) = x - 1
i = x
ElseIf x = 0 And Z = 0 And zz = 0 Then
n = n + 1
brr(n, 1) = i
For k = UBound(arr) To i Step -1
If arr(k, 1) <> 0 Then Exit For
Next
brr(n, 2) = k
i = UBound(arr)
ElseIf x = 0 And m > 0 Then
n = n + 1
brr(n, 1) = i
brr(n, 2) = m - 1
i = m
ElseIf x > m And x > 0 And Z < zz Then
n = n + 1
brr(n, 1) = i
brr(n, 2) = Z + 1
i = Z
ElseIf x > m And x > 0 And Z > zz Then
n = n + 1
brr(n, 1) = i
brr(n, 2) = zz - 1
i = zz
End If
End If
End If
Next
For i = 1 To n
x = 0
If brr(i, 2) - brr(i, 1) >= 4 Then
For k = brr(i, 1) To brr(i, 2)
x = x + IIf(arr(k, 1) > 0, 1, 0)
Next
If x >= 5 Then
For k = brr(i, 1) To brr(i, 2)
crr(k, 1) = x
Next
End If
End If
Next
[d11].Resize(UBound(brr)) = crr
' [k11].Resize(UBound(brr), 2) = brr
Beep
End If
Application.EnableEvents = True
End Sub
|
评分
-
1
查看全部评分
-
|