Excel表中删除重复数据方法
Sub tt()
Application.ScreenUpdating = False
Dim a As Integer
Sheets(4).Range("A2:D1000").ClearContents
Sheets(5).Range("A2:D1000").ClearContents
With Sheets(2)
a = .[a65536].End(3).Row
c = 2:
d = 2
For i = 2 To a
b = Application.CountIf(Sheets(1).Range("B:B"), .Cells(i, 2))
If b > 0 Then
.Range("A" & i, "D" & i).Copy Sheets(4).Cells(c, 1)
c = c + 1
Else
.Range("A" & i, "D" & i).Copy Sheets(5).Cells(d, 1)
d = d + 1
End If
Next
End With
Application.ScreenUpdating = True
End Sub
'b=application.countif(sheets(1).Range("A:A"),sheets(2).Cells(i,1))
'countif为统计满足条件的个数,其中sheets(1).Range("A:A")为满足条件的单元格为A列,
'sheets(2).Cells(i,1)为统计条件,其中i为行,1为列,cells为比较函数
'Range("A" & i, "D" & i).Copy Sheets(4).Cells(c, 1)
拷贝A到D列的所有内容至表4
'Sheets(4).Range("A2:C1000").ClearContents
'清除"表4"中"A2:C1000"区域内的所有内容
'特别提示:运行起来较快,但仅有删除功能,也就是说运行后只能看见你想要的数据,其它被删除的将不会被看见。
闽公网安备 35021102001881号 
热门文档