|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton1_Click()
Set d = CreateObject("scripting.dictionary") '字典后期绑定
Dim sht As Worksheet
r = 0
Dim brr()
ReDim brr(1 To 50000, 1 To 3)
For Each sht In Worksheets
If sht.Name <> "你好" Then
arr = sht.UsedRange
For j = 4 To UBound(arr)
If arr(j, 7) <> "" Then
If d.exists(arr(j, 7)) Then
x = d(arr(j, 7))
brr(x, 2) = brr(x, 2) + 1
brr(x, 3) = brr(x, 3) + arr(j, 9)
Else
r = r + 1
brr(r, 1) = arr(j, 7)
brr(r, 2) = 1
brr(r, 3) = arr(j, 9)
d(arr(j, 7)) = r
End If
End If
Next
End If
Next
If r > 0 Then
Range("k2").Resize(r, 3) = brr
End If
End Sub
Private Sub CommandButton2_Click()
Set d = CreateObject("scripting.dictionary") '字典后期绑定
Dim sht As Worksheet
r = 0
arr = Sheet1.UsedRange
Dim brr()
ReDim brr(1 To UBound(arr), 1 To 3)
For j = 4 To UBound(arr)
If arr(j, 7) <> "" Then
If d.exists(arr(j, 7)) Then
x = d(arr(j, 7))
brr(x, 2) = brr(x, 2) + 1
brr(x, 3) = brr(x, 3) + arr(j, 9)
Else
r = r + 1
brr(r, 1) = arr(j, 7)
brr(r, 2) = 1
brr(r, 3) = arr(j, 9)
d(arr(j, 7)) = r
End If
End If
Next
If r > 0 Then
Range("a2").Resize(r, 3) = brr
End If
End Sub
|
|