|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 microyip 于 2016-11-25 17:43 编辑
- Sub 不重复月份数()
- Dim d As Object, d1 As Object, d2 As Object, i%, Arr
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- Range("F2:P8").ClearContents
- Arr = [A1].CurrentRegion.Value
- For i = 2 To UBound(Arr)
- If Not d.Exists(Arr(i, 1) & Arr(i, 2)) Then
- d(Arr(i, 1) & Arr(i, 2)) = 0
- d1(Arr(i, 1)) = d1(Arr(i, 1)) + 1
- End If
- d2(Arr(i, 1)) = d2(Arr(i, 1)) + 1
- Next
- Range("F2").Resize(d1.Count, 1) = Application.Transpose(d1.Keys)
- Range("G2").Resize(d1.Count, 1) = Application.Transpose(d1.Items)
- Range("H2").Resize(d1.Count, 1) = Application.Transpose(d2.Items)
- End Sub
复制代码
|
|