'跟示例结果不一样?
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row < 13 Or Target.Row > 33 Or Target.Column < 5 Or Target.Column > 108 Then Exit Sub
Application.EnableEvents = True
Dim arr, i, j, title, mark
ReDim brr(1 To 18, 9)
arr = [e13:dd33]
For i = Target.Row - 12 To Target.Row - 12 + 17
For j = Target.Column - 4 To Target.Column - 4 + 49
If i <= UBound(arr, 1) And j <= UBound(arr, 2) Then
brr(i - Target.Row + 12 + 1, Val(Right(arr(i, j), 1))) = _
brr(i - Target.Row + 12 + 1, Val(Right(arr(i, j), 1))) + 1
End If
Next j, i
title = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
ReDim mark(1 To UBound(brr, 1), 1 To 1)
For i = Target.Row To Target.Row + UBound(mark, 1) - 1
mark(i - Target.Row + 1, 1) = i & "行各数个数"
Next
Rows(40).Resize(UBound(arr, 1) + 1).ClearContents
With Cells(40, Target.Column)
.Resize(, UBound(title) + 1) = title
.Offset(1, -4).Resize(UBound(mark, 1)) = mark
.Offset(1).Resize(UBound(brr, 1), UBound(brr, 2) + 1) = brr
End With
Application.EnableEvents = True
End Sub |