【VBA】VBA实现统计目标范围内重复值次数
来源:互联网 发布:linode windows 编辑:程序博客网 时间:2024/05/21 11:29
Sub f()Set myb = CreateObject("scripting.dictionary"): myb("PICSID") = "出现次数"Set Rng = Application.InputBox("选择统计区域:", Type:=8)ActiveSheet.Cells.Interior.ColorIndex = 0Rng.Interior.ColorIndex = 3For Each rng1 In Rng myb(rng1.Value) = Application.WorksheetFunction.CountIf(Rng, rng1)NextSet rng3 = Application.InputBox("选择输出地方:", Type:=8)With rng3 .Resize(myb.Count) = Application.Transpose(myb.keys) .Offset(, 1).Resize(myb.Count) = Application.Transpose(myb.items)End WithSet myb = Nothing: Set rng3 = NothingEnd Sub