asked on
Sub RemoveDuplicateWorkOrders()
Dim wsData As Worksheet
Dim lr As Long
Application.ScreenUpdating = False
Set wsData = Worksheets("PA08")
wsData.AutoFilterMode = False
lr = wsData.Cells(Rows.Count, 1).End(xlUp).Row
wsData.Range("Z2:Z" & lr).Formula = "=D2<>MAXIFS($D$2:$D$" & lr & ",$A$2:$A$" & lr & ",A2)"
With wsData.Range("Z1:Z" & lr)
.AutoFilter field:=1, Criteria1:=True
If .SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
wsData.Range("Z2:Z" & lr).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End If
.AutoFilter
.ClearContents
End With
wsData.Range("A1").AutoFilter
Application.ScreenUpdating = True
End Sub
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY