I am using following line to remove duplicates in column.
ActiveSheet.Range("A:B").RemoveDuplicates Columns:=Array(1, 1), Header:=xlYes
Problem is, this is done silently and I don't really know when my data has double values.
I need know by using Msgbox
that if duplicates are deleted or not. Is it possible using Count
to mention number of entries deleted? in simplest code.
Try:
Dim lr As Long
With ActiveSheet
lr = .Cells(.Rows.Count, 1).End(xlUp).row
.Range("A:B").RemoveDuplicates Columns:=Array(1, 1), Header:=xlYes
If Not lr - .Cells(.Rows.Count, 1).End(xlUp).row = 0 Then
MsgBox lr - .Cells(.Rows.Count, 1).End(xlUp).row & " Rows Deleted"
End If
End With
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.