Dear Excel-Experts,
after failing on my own with various builds, I decided to ask the experts for advice
What do i want to do?
My goal is to fill the column "Amout of toCount (different)" on sheet: "SHOW"
This column should tell me the number of all different "toCount" values of the sheet: "Database".
Example:
Key A
In the database A is mentioned 3 times, but the first and the third time "toCount"-Value is the same (222) so the result is 2.
Key B
mentioned 2 times - both have the same "toCount" -> result = 1
Key C
mentioned 4 times with 3 different "toCount" -> result = 3
I have successfully written a program in which I query a specific key, but I can't manage to convert it to a list (on another sheet):
WS_DB, Z_DB__Start ... are declared in "DB_INFO"
The code example does not exactly match the tables above - they are anoymized. It should only present my progress.
Maybe someone can help me.
Many thanks in Advance
MK91
after failing on my own with various builds, I decided to ask the experts for advice
What do i want to do?
Database | ||||
---|---|---|---|---|
A | B | |||
1 | WS DB | |||
2 | KEY | toCount | ||
3 | A | 222 | ||
4 | B | 456 | ||
5 | E | 358 | ||
6 | C | 125 | ||
7 | H | 256 | ||
8 | D | 897 | ||
9 | S | 799 | ||
10 | C | 562 | ||
11 | A | 489 | ||
12 | B | 456 | ||
13 | A | 222 | ||
14 | E | 358 | ||
15 | G | 114 | ||
16 | F | 875 | ||
17 | C | 763 | ||
Tabelle1 |
SHOW | ||||
---|---|---|---|---|
D | E | |||
2 | KEY | Amount of toCount (different) | ||
3 | A | 2 | ||
4 | B | 1 | ||
5 | C | 3 | ||
6 | D | 1 | ||
7 | E | 1 | ||
Tabelle1 |
My goal is to fill the column "Amout of toCount (different)" on sheet: "SHOW"
This column should tell me the number of all different "toCount" values of the sheet: "Database".
Example:
Key A
In the database A is mentioned 3 times, but the first and the third time "toCount"-Value is the same (222) so the result is 2.
Key B
mentioned 2 times - both have the same "toCount" -> result = 1
Key C
mentioned 4 times with 3 different "toCount" -> result = 3
I have successfully written a program in which I query a specific key, but I can't manage to convert it to a list (on another sheet):
VBA Code:
Sub simpleCountifDictionary()
Dim dictX As Object, strX As String, vARR_DB As Variant
Set dictX = CreateObject("scripting.Dictionary")
strX = "EXAMPLE"
Call DB__INFO
With WS_DB
vARR_DB = .Range(.Cells(Z_DB__Start, S_DB__Start), .Cells(Z_DB__End, S_DB__End))
For z = 1 To UBound(vARR_DB)
If vARR_DB(z, S_DB__Zuo__Person) = strX Then
dictX(vARR_DB(z, S_DB__PNr)) = vARR_DB(z, S_DB__PNr) + 1
End If
Next z
End With
Debug.Print dictX.Count
End Sub
WS_DB, Z_DB__Start ... are declared in "DB_INFO"
The code example does not exactly match the tables above - they are anoymized. It should only present my progress.
Maybe someone can help me.
Many thanks in Advance
MK91