|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
排重、提取最高价- Sub ykcbf() '//2024.7.12
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 2)
- ReDim brr(1 To UBound(arr), 1 To 2)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- brr(m, 2) = arr(i, 2)
- Else
- r = d(s)
- brr(r, 2) = IIf(brr(r, 2) < arr(i, 2), arr(i, 2), brr(r, 2))
- End If
- Next
- .[g2:h1000] = ""
- .[g2].Resize(m, 2) = brr
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|