Hello,
I am writing to you because I am having problems with a macro I created (with help of some online forums).
I want the macro to delete all rows that on column AE have the text "Duplicate".
In addition, I would also want that before running the macro, a pop up appears asking "do you really want to delete duplicates?".
Finally, one more thing that I would like the macro to do is show in a message box the number of rows that have been deleted.
You can find the macro below
I would GREATLY appreciate your help,
Xabier
This is the macro I have written:
Sub delete_duplicates()
'ask if really want to delete'
On Error GoTo Err_btnDeleteRecord_Click
Dim Answer As Integer
Answer = MsgBox("Are you sure you wish to delete duplicates?", vbYesNo + vbExclamation + vbDefaultButton2, "Delete Confirmation")
If Answer = vbYes Then
'direct where'
With ThisWorkbook.Sheet4
'remove filters'
.AutoFilterMode = False
'filter rows that on column AE have text "duplicate"'
With Range("AE1", Range("AE" & Rows.Count).End(xlUp))
.AutoFilter 1, "Duplicate"
On Error Resume Next
'delete these rows'
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
'remove filter'
.AutoFilterMode = False
MsgBox 'Number of deletions' & = 57241 - (rowCount = Application.WorksheetFunction.CountA(Range(“AE2:AE57241”))
End Sub
Solved by D. H. in 13 mins