|
参与一下。。。
- Sub ykcbf() '//2024.8.9
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- xm = .[n2].Value
- rq1 = CDate(.[q2].Value): rq2 = CDate(.[r2].Value)
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 12)
- For i = 2 To UBound(arr)
- If arr(i, 7) >= rq1 And arr(i, 7) <= rq2 Then
- If arr(i, 1) = xm Then
- s = arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 4) & "|" & arr(i, 5) & "|" & arr(i, 6)
- If Not d.exists(s) Then
- d(s) = Array(1, arr(i, 8) + arr(i, 10))
- Else
- t = d(s)
- t(0) = t(0) + 1
- t(1) = t(1) + arr(i, 8) + arr(i, 10)
- d(s) = t
- End If
- End If
- End If
- Next
- ReDim brr(1 To d.Count, 1 To 8)
- For Each k In d.keys
- m = m + 1
- brr(m, 1) = xm
- b = Split(k, "|")
- For x = 0 To UBound(b)
- brr(m, x + 2) = b(x)
- Next
- brr(m, 8) = Round(d(k)(1) / d(k)(0), 2)
- Next
- .[n6].Resize(10, 8) = ""
- .[n6].Resize(m, 8) = brr
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|