|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub qs() '2024/6/27
Dim arr, brr, dic, i
Set dic = CreateObject("scripting.dictionary")
With Sheet1
.Range("d2:f10000").ClearContents
arr = .Range("a1").CurrentRegion.Value
ReDim brr(1 To UBound(arr), 1 To 3)
For i = 2 To UBound(arr)
s = arr(i, 1) & arr(i, 2)
If Not dic.exists(s) Then
m = m + 1
dic(s) = m
brr(m, 1) = arr(i, 1)
brr(m, 2) = arr(i, 2)
brr(m, 3) = 1
Else
rw = dic(s)
brr(rw, 3) = brr(rw, 3) + 1
End If
Next
.Range("d2").Resize(m, 3) = brr
End With
Set dic = Nothing
MsgBox "完成!"
End Sub |
|