Set d = CreateObject("scripting.dictionary")
With Sheet1 '
Dim d1, d2, d3 '取三个关键字为字典key
Arr = .[b1].CurrentRegion
stime = DTPicker1.Value: etime = DTPicker2.Value
For i = 2 To UBound(Arr)
If Arr(i, 2) >= stime And Arr(i, 2) <= etime Then
d1(Arr(i, 12)) = d1(Arr(i, 12)) + 1
d2(Arr(i, 13)) = d2(Arr(i, 13)) + 1
d3(Arr(i, 14)) = d3(Arr(i, 14)) + 1
End If
Next
End With
With Sheet2
.Cells(2, 1).Resize(d1.Count, 1) = Application.Transpose(d1.keys)
.Cells(2, 2).Resize(d1.Count, 1) = Application.Transpose(d1.items)
.Cells(3, 1).Resize(d2.Count, 1) = Application.Transpose(d2.keys)
.Cells(3, 2).Resize(d2.Count, 1) = Application.Transpose(d2.items)
.Cells(4, 1).Resize(d3.Count, 1) = Application.Transpose(d3.keys)
.Cells(4, 2).Resize(d3.Count, 1) = Application.Transpose(d3.items)
End With
我这个vba 字典代码哪里错误?
答案:1 悬赏:10 手机版
解决时间 2021-02-28 19:53
- 提问者网友:鐵馬踏冰河
- 2021-02-28 01:51
最佳答案
- 五星知识达人网友:上分大魔王
- 2021-02-28 02:57
你其实是用了3个字典对像,D1,D2,D3。而且看你的代码是后添加,所以需要
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
SUB完结前,最好加上 SET D1=NOTHING
其他的类似这样操作
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
SUB完结前,最好加上 SET D1=NOTHING
其他的类似这样操作
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯