我从 g (对象)中提取键值很好,但是它们在 M 范围内相互覆盖,我不明白,因为它应该寻找偏移量?我显然错过了一些东西。有任何想法吗?谢谢!
With wbkVer.Worksheets(1)
Set g = CreateObject("scripting.dictionary")
Set rngChasssSrc = wbkCS.Worksheets(2).Range("Z3:Z20")
Set rngchassis = wbkVer.Worksheets(1).Range("M" & .Rows.Count).End(xlUp).Offset(1, 0)
For Each k In rngChasssSrc
tmp = Trim(Right(k.Value, 7))
If Not IsEmpty(tmp) Then g(tmp) = g(tmp) + 1
Next k
For Each u In g.Keys()
rngchassis.Value = u
Next u
End With
最终代码:
With wbkVer.Worksheets(1)
Set g = CreateObject("scripting.dictionary")
Set rngChasssSrc = wbkCS.Worksheets(2).Range("Z3:Z20")
Set rngchassis = .Range("M" & .Rows.Count).End(xlUp).Offset(1, 0)
For Each k In rngChasssSrc
If k > 0 then
tmp = Trim(Right(k.Value, 7))
If Not IsEmpty(tmp) Then g(tmp) = g(tmp) + 1
End if
Next k
For Each u In g.Keys()
rngchassis.Value = u
Set rngchassis = .Range("M" & .Rows.Count).End(xlUp).Offset(1, 0)
Next u
End With