|
统计。。。
- Sub ykcbf() '//2024.11.29
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1 (2)")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 10)
- End With
- With Sheets("Sheet1")
- rq1 = .[b3].Value
- rq2 = .[e3].Value
- For i = 4 To UBound(arr)
- rq = CDate(arr(i, 10))
- If rq >= rq1 And rq <= rq2 Then
- s = arr(i, 2)
- d(s) = d(s) + 1
- End If
- Next
- .[g3] = d.Count & "个"
- d.RemoveAll
- For i = 4 To UBound(arr)
- rq = CDate(arr(i, 10))
- If rq >= rq1 And rq <= rq2 Then
- s = arr(i, 2) & "-" & arr(i, 5)
- If Not d.exists(s) Then
- d(s) = arr(i, 4)
- End If
- End If
- Next
- Sum = 0
- For Each k In d.keys
- Sum = Sum + d(k)
- Next
- .[h3] = Sum & "个"
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|