|
用事件来完成:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim D As New Dictionary
Dim I As Integer
Dim ARR
ARR = Range("A2:C111")
For I = 1 To UBound(ARR, 1)
If ARR(I, 2) = Range("G1") Then
D(ARR(I, 1)) = D(ARR(I, 1)) + ARR(I, 3)
End If
Next
Range("F3:G15").ClearContents
Range("F3").Resize(D.Count, 1) = Application.WorksheetFunction.Transpose(D.Keys)
Range("G3").Resize(D.Count, 1) = Application.WorksheetFunction.Transpose(D.Items)
D.RemoveAll
End Sub
|
评分
-
查看全部评分
|