Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I would like to improuve my ability to use dictionary, but unfortunately I have problem in understanding how they work.
For example, in the case below, the result in column C has to be the number of different values in column B for each value in column A. (You can see the result on column C in gray).
https://imgur.com/a/sHEh2Uc
I've tried this way:
and then?
Something like
?
I would like to improuve my ability to use dictionary, but unfortunately I have problem in understanding how they work.
For example, in the case below, the result in column C has to be the number of different values in column B for each value in column A. (You can see the result on column C in gray).
https://imgur.com/a/sHEh2Uc
I've tried this way:
Code:
Sub count()
Dim s1
Dim lr As Long, i As Long, n As Long
Dim rng As Range
Dim x, dict, it
Set s1 = Sheets("Sheet 1")
s1.AutoFilterMode = False
lr = s1.Cells(Rows.count, 1).End(xlUp).Row
x = s1.Range("A2:A" & lr)
Set dict = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(x, 1)
dict.Item(x(i, 1)) = ""
Next i
For Each it In dict.keys
and then?
Something like
Code:
.AutoFilter 1, it
?