|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim dic As Object, t, i, arr
Set dic = CreateObject("scripting.dictionary")
arr = Sheet2.Range([c2], Cells(Rows.Count, "f").End(xlUp))
ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
For i = LBound(arr) To UBound(arr)
t = arr(i, 1) & "#" & arr(i, 2)
If Not dic.exists(t) Then
dic(t) = ""
brr(i, 1) = arr(i, 1)
brr(i, 2) = arr(i, 2)
brr(i, 3) = arr(i, 3)
brr(i, 4) = arr(i, 4)
Else
brr(i, 1) = arr(i, 1)
brr(i, 2) = arr(i, 2)
brr(i, 3) = arr(i, 3)
brr(i, 4) = ""
End If
Next i
Sheet2.Range("i2").Resize(UBound(brr), UBound(brr, 2)) = brr
End Sub |
|