Hi, Andrew,
please give this macro a try:
Sub EF1023431()
Dim lngRC As Long
Dim blnDel As Boolean
For lngRC = Range("A" & Rows.Count).End(xlUp).Row To 4 Step -1
If WorksheetFunction.CountIf(Range("A3:A" & Range("A" & Rows.Count).End(xlUp).Row), Cells(lngRC, "A").Value) > 1 Then
Select Case Cells(lngRC, "C").Value
Case "D"
If blnDel Then Rows(lngRC).Delete
blnDel = True
Case "N"
If blnDel Then Rows(lngRC).Delete
blnDel = True
Case Else
Rows(lngRC).Delete
End Select
End If
If Cells(lngRC, "A").Value <> Cells(lngRC - 1, "A").Value Then blnDel = False
Next lngRC
End Sub
It should be run on a copy with the data of Pre.
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
HTH,
Holger
Bookmarks