|
代码如下。。。
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$P$1" Then
arr = [k10:k72]
ReDim brr(1 To UBound(arr), 1 To 2)
For i = 1 To UBound(arr) - 1
If arr(i, 1) > 1 Then
n = n + 1
For j = i + 1 To UBound(arr) - 1
If arr(j, 1) = 1 Then
brr(j, 2) = n
i = j
n = 0
Exit For
Else
If arr(j, 1) = 0 And arr(j + 1, 1) > 1 Then n = n + 1
End If
Next
x = i + 1
If UBound(arr) = x Then
If arr(x, 1) > 1 Then brr(x, 2) = n
End If
End If
Next
For i = 1 To UBound(arr) - 1
If arr(i, 1) > 1 Then
brr(i, 1) = m
m = 0
ElseIf arr(i, 1) = 1 Then
m = m + 1
End If
x = i + 1
If UBound(arr) = x Then
If arr(x, 1) = 0 Or arr(x, 1) = 1 Then brr(x, 1) = m + arr(x, 1)
End If
Next
For i = 1 To UBound(brr)
For j = 1 To 2
If brr(i, j) = Empty Then brr(i, j) = 0
Next
Next
[p10].Resize(UBound(brr), 2) = brr
End If
Application.EnableEvents = True
End Sub
|
评分
-
1
查看全部评分
-
|