Option
Explicit
Public
Sub
Beispiel()
Dim
dic
As
Object
Dim
dtm(0
To
4)
As
Date
Dim
key0
As
String
Dim
keyJ
As
String
Dim
i
As
Long
Dim
j
As
Long
For
i = 3
To
5
dtm(0) = Worksheets(
"data"
).Cells(i,
"C"
).Value
dtm(1) = Worksheets(
"data"
).Cells(i,
"D"
).Value
dtm(2) = Worksheets(
"data"
).Cells(i,
"E"
).Value
dtm(3) = Worksheets(
"data"
).Cells(i,
"F"
).Value
dtm(4) = Worksheets(
"data"
).Cells(i,
"G"
).Value
key0 = Format$(dtm(0),
"yyyy-mm-01"
)
Set
dic = CreateObject(
"Scripting.Dictionary"
)
For
j = 1
To
4
keyJ = Format$(dtm(j),
"yyyy-mm-01"
)
If
CDate
(key0) <
CDate
(keyJ)
Then
If
Not
dic.Exists(keyJ)
Then
dic(keyJ) = Empty
End
If
End
If
Next
Worksheets(
"data"
).Cells(i,
"B"
).Value = dic.Count
Next
End
Sub