|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下。。。
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$H$1" Then
arr = [e51:e251]
ReDim brr(1 To UBound(arr), 0)
For i = 1 To UBound(arr)
If arr(i, 1) > 0 Then
arr(i, 1) = 1
Else
arr(i, 1) = 0
End If
s = s & CStr(arr(i, 1))
brr(i, 0) = 0
Next
For i = 1 To Len(s)
x = InStr(i, s, "000")
If IsNumeric(x) And x <> 0 Then
brr(x + 2, 0) = 100
i = x
Else
Exit For
End If
Next
For i = 1 To Len(s)
x = InStr(i, s, "0")
y = InStr(i, s, "1")
If x > y And y > 0 Then
yy = InStr(Mid(s, x + 1), "1")
xx = InStr(Mid(s, x + 1), "0")
If (x - y = xx - yy) Or (x - y = zz) Then
i = x + xx - 1
If x - y = xx - yy Then
brr(i + 1, 0) = xx - 1
ElseIf zz > 0 Then
brr(i, 0) = zz
End If
zz = 0
Else
zz = xx - yy
i = x + xx - 1
End If
End If
Next
[h51].Resize(UBound(brr)) = brr
Beep
End If
Application.EnableEvents = True
End Sub
|
评分
-
1
查看全部评分
-
|