|
Option Explicit
Dim last, sum
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 3 Or Target.Row > 22 Or Target.Column <> 2 Or _
CDec(Target.Rows.Count) * Target.Columns.Count > 1 Then Exit Sub
If Not IsArray(last) Then reset
If Len(Target) = 0 Then
sum(Target.Row - 2, 1) = 0
Target.Offset(, 1) = ""
Exit Sub
End If
If Target <> last(Target.Row - 2, 1) Then
If Len(last(Target.Row - 2, 1)) > 0 Then
last(Target.Row - 2, 1) = Target
sum(Target.Row - 2, 1) = sum(Target.Row - 2, 1) + 1
[c3].Resize(UBound(sum, 1)) = sum
Else
last(Target.Row - 2, 1) = Target
End If
End If
End Sub
Sub reset()
ReDim last(1 To 20, 1 To 1): sum = last
End Sub |
评分
-
1
查看全部评分
-
|