|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim dic As Object: Set dic = CreateObject("scripting.dictionary")
Dim arr, i As Integer, brr(1 To 1000, 1 To 1), j As Integer
arr = Range([a4], Cells(Rows.Count, 4).End(xlUp))
For i = 1 To UBound(arr)
If Not dic.exists(arr(i, 1)) Then
dic(arr(i, 1)) = i
End If
Next i
For i = 0 To dic.Count - 1
For j = 1 To UBound(arr)
If InStr(1, arr(j, 4), dic.keys()(i), vbTextCompare) > 0 Then
brr(dic(arr(i + 1, 1)), 1) = brr(dic(arr(i + 1, 1)), 1) + 1
End If
Next j
Next i
[d4].Resize(dic.Count, 1) = brr
End Sub
|
|