代码如下,,,
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$N$1" Then
arr = [h21:h220]
ReDim brr(1 To UBound(arr), 0)
For i = 1 To UBound(arr)
If arr(i, 1) > 1 Then arr(i, 1) = 2
s = s & arr(i, 1)
Next
For m = 1 To UBound(arr)
i = InStr(m, s, "2")
x = InStr(i, s, "0")
y = InStr(i, s, "1")
Z = Application.Min(x, y)
If y > 0 Then ii = InStr(y, s, "2")
If ii > y And y <> 0 Then
ss = Mid(s, i, y - i + 1)
zZ = InStrRev(ss, "2")
j = j + 1
brr(j, 0) = zZ
j = j + 1
brr(j, 0) = ii - zZ - i
m = ii - 1
ElseIf ii = 0 And y > 0 Then
ss = Mid(s, i, y - i + 1)
zZ = InStrRev(ss, "2")
j = j + 1
brr(j, 0) = zZ
j = j + 1
brr(j, 0) = 201 - zZ - i
m = 200
End If
If y = 0 Then
j = j + 1
brr(j, 0) = 201 - i
m = 200
End If
Next
With Sheet3
.Range(.[n78], .[n78].End(3)).ClearContents
.[n78].Offset(-j + 1).Resize(j) = brr
End With
End If
Application.EnableEvents = True
End Sub
|