|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 提取不重复的记录()
- Dim ar, re, d As Object
- Dim i As Long, cnt As Long, j As Integer
- ar = Sheets(1).Range("A1").CurrentRegion
- Set d = CreateObject("Scripting.Dictionary")
- ReDim re(1 To UBound(ar), 1 To UBound(ar, 2))
- For i = 2 To UBound(ar)
- If Not d.exists(ar(i, 1) & Format(ar(i, 3), "ee-mm-dd")) Then
- cnt = cnt + 1
- d(ar(i, 1) & Format(ar(i, 3), "ee-mm-dd")) = cnt
- For j = 1 To UBound(ar, 2)
- re(cnt, j) = ar(i, j)
- Next j
- End If
- Next i
- Sheets(2).[a1].Resize(cnt, UBound(re, 2)) = re
- End Sub
复制代码 |
|