adding +1 to occurence

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: adding +1 to occurence

Post by sal21 »

HansV wrote:C'mon Sal, you can do this!
.....
Dim DIC2 As Object
Set DIC2 = CreateObject("Scripting.Dictionary")

...
If DIC.Exists(CHIAVE) Then
DIC(CHIAVE) = DIC(CHIAVE) + CONTANTI
DIC2(CHIAVE) = DIC2(CHIAVE) + 1
Else
DIC.Add CHIAVE, CONTANTI
DIC2.Add CHIAVE, 1
End If
...

If this piece of code is good, how to change the loop in fore ecah? perpahs:

For Each varEntry In DIC
Debug.Print varEntry & "-" & DIC(varEntry) & "-" & DIC2(varEntry)
Next varEntry

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: adding +1 to occurence

Post by HansV »

See? You can do it! Your code looks fine.
Best wishes,
Hans