【发布时间】:2013-12-14 13:12:15
【问题描述】:
我需要一个公式或函数来满足我下面提到的需求。我有大约 11000 行的 excel 数据,数据看起来有点像 A 列中的数据: 现在在 B 列中,我希望像下面提到的那样打印结果:字面意思是它应该计算 A 列中存在的值并将其打印在 B 列中,我不需要重复计数:
Column A Column B
PC-101 1
PC-101 1
PC-102 2
PC-102 2
PC-103 3
PC-104 4
PC-106 5
PC-107 6
PC-104 4
PC-106 5
PC-106 5
我尝试使用“计数”系列公式,但结果为空。 即使我写了如下给出的宏(我从stackoverflow获得),但即使它正在打印重复计数:
子计数发生() ' 参考:Microsoft 脚本运行时 Application.ScreenUpdating = False 设置 oDict = 新词典 将 wS 调暗为工作表 Dim r As Integer, rLast As Integer 设置 wS = Sheet1 rLast = wS.Cells(1, 1).CurrentRegion.Rows.Count For r = 3 To rLast Step 1 如果不是 (oDict.Exists(wS.Cells(r, 1).Value)) 那么 oDict.Add wS.Cells(r, 1).Value, 1 别的 oDict.Item(wS.Cells(r, 1).Value) = oDict.Item(wS.Cells(r, 1).Value) + 1 万一 wS.Cells(r, 2).Value = oDict.Item(wS.Cells(r, 1).Value) 下一个 设置 oDict = 无 Application.ScreenUpdating = True 结束子有人可以帮我解决这个问题吗?提前致谢。
【问题讨论】:
标签: vba excel excel-formula