|
如何用VBA计算不同分组的“不重复”客户数?求指导啊,不尽感激
- Sub x()
- Dim a, d, d1, x%, b, c(), s%
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- a = Range("a1").CurrentRegion
- For x = 2 To UBound(a)
- d(a(x, 2)) = d(a(x, 2))
- Next
- b = d.keys
- ReDim c(1 To d.Count, 1 To 2)
- For x = 1 To d.Count
- c(x, 1) = b(x - 1)
- For s = 2 To UBound(a)
- If a(s, 2) = c(x, 1) Then d1(b(x - 1) & a(s, 1)) = ""
- Next
- c(x, 2) = d1.Count: d1.RemoveAll
- Next
- [e1].Resize(d.Count, 2) = c
- End Sub
复制代码
|
-
-
数据.zip
133.64 KB, 下载次数: 19
源数据
|