|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("a1").CurrentRegion.Value
- ReDim brr(1 To UBound(arr), 1 To 4)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not dic.exists(s) Then
- m = m + 1
- dic(s) = m
- For j = 1 To 4
- brr(m, j) = arr(i, j)
- Next
- Else
- r = dic(s)
- If CDate(brr(r, 3)) > CDate(arr(i, 3)) Then brr(r, 3) = CDate(arr(i, 3))
- If CDate(brr(r, 4)) < CDate(arr(i, 4)) Then brr(r, 4) = CDate(arr(i, 4))
- End If
- Next
- Sheet2.Range("a2").Resize(m, 4) = brr
- End Sub
复制代码 |
|