Sub f()
Set myb = CreateObject("scripting.dictionary"): myb("PICSID") = "出现次数"
Set Rng = Application.InputBox("选择统计区域:", Type:=8)
ActiveSheet.Cells.Interior.ColorIndex = 0
Rng.Interior.ColorIndex = 3
For Each rng1 In Rng
myb(rng1.Value) = Application.WorksheetFunction.CountIf(Rng, rng1)
Next
Set rng3 = Application.InputBox("选择输出地方:", Type:=8)
With rng3
.Resize(myb.Count) = Application.Transpose(myb.keys)
.Offset(, 1).Resize(myb.Count) = Application.Transpose(myb.items)
End With
Set myb = Nothing: Set rng3 = Nothing
End Sub【VBA】VBA实现统计目标范围内重复值次数
最新推荐文章于 2025-11-23 14:09:06 发布
本文介绍了一个使用VBA实现的统计函数示例,该函数可以统计指定区域内各数值的出现次数,并将统计结果输出到指定位置。通过创建Dictionary对象来记录每个数值及其对应的出现次数,再利用CountIf函数进行计数。
1006

被折叠的 条评论
为什么被折叠?



