|
本帖最后由 small_small 于 2022-12-14 17:14 编辑
- Sub test()
- Dim d, dstr, k, i, n, arr, brr(), str
- arr = Sheet1.Range("a1").CurrentRegion
- ReDim brr(1 To 1000, 1 To 3)
- Set d = CreateObject("scripting.dictionary")
- For k = 2 To UBound(arr)
- dstr = VBA.Year(arr(k, 4))
- If dstr < 2022 Then
- d(arr(k, 13)) = ""
- Else
- If Not d.exists(arr(k, 13)) Then
- str = VBA.Month(arr(k, 4))
- d(arr(k, 13)) = ""
- n = n + 1
- brr(n, 1) = str & "月新客户"
- brr(n, 2) = arr(k, 12)
- brr(n, 3) = arr(k, 13)
- End If
- End If
- Next k
- Sheet2.Range("a2").Resize(n, 3) = brr
- End Sub
复制代码 |
|