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