0
需要帮助删除行,我有下面这段代码:包含重复值
Dim LRAS, matchFoundIndex, iCntr As Long
LRAS = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
For iCntr = 3 To LRAS
If Cells(iCntr, 1) <> "" Then
matchFoundIndex = WorksheetFunction.Match(Cells(iCntr, 1), Range("A1:A" & LRAS), 0)
If iCntr <> matchFoundIndex Then
Cells(iCntr, 14) = "Duplicate"
'at this point duplicate
End If
End If
Next iCntr
'-----------
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim deleteRow As Long
Dim wrksht As Worksheet
Set wrksht = ActiveSheet
For deleteRow = wrksht.Range("N" & Rows.Count).End(xlUp).Row To 3 Step -1
If wrksht.Range("N" & deleteRow).Value = "Duplicate" Then
Rows(deleteRow).EntireRow.Delete
End If
Next deleteRow
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
此代码basicly搜索重复值,然后说,值是重复的。下一步是删除第二个重复项目。 我想将此构建成一个事件而不是两个分离的事件。有没有办法做到这一点?还是有另一种方法来删除基于第一列中的值的重复行?
谢谢,我要去尝试了这一点.. – Tarik