- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- With Sheet1
- arr = .Range("a1").CurrentRegion.Value
- ReDim brr(1 To UBound(arr), 1 To 3)
- For i = 2 To UBound(arr)
-
- If arr(i, 4) = "" Then arr(i, 4) = arr(i - 1, 4)
- If arr(i, 3) = "" Then arr(i, 3) = arr(i - 1, 3)
- s = arr(i, 4)
- If Not dic.exists(s) Then
- m = m + 1
- dic(s) = m
- brr(m, 1) = s: brr(m, 2) = arr(i, 3): brr(m, 3) = CDate(arr(i, 2))
- Else
- r = dic(s)
- If brr(r, 3) < CDate(arr(i, 2)) Then brr(r, 3) = CDate(arr(i, 2)): brr(r, 2) = arr(i, 3)
- End If
- Next i
- .Range("i2").Resize(m, 2) = brr
- End With
- Set dic = Nothing
- End Sub
复制代码 |