Excel vba MsgBox在find重复项时显示消息

我试图从Excel表中删除重复项,我有一段代码,删除重复没有任何问题,我想知道如果我可以提示消息框时,发现重复的东西沿线说“这个条目是一个重复的条目“有什么build议吗? 这是我到目前为止:

Sub AccessTransfer() Range("A1:F1").Select Selection.Copy Sheets("Sheet2").Select ActiveSheet.Paste ActiveCell.Offset(0, 6).Value = "Oven" Range("A65536").End(xlUp).Offset(1, 0).Select Call GoDupe Sheets("Sheet1").Select Application.CutCopyMode = False End Sub Sub GoDupe() Cells.RemoveDuplicates Columns:=Array(1), Header:=xlNo Range("A65536").End(xlUp).Offset(1, 0).Select End Sub 

而不是循环,识别和提示每个重复,你可以简单地突出显示所有重复,并提示用户一次。 你的GoDupe()子可能看起来像这样:

 Sub GoDupe() Cells.FormatConditions.AddUniqueValues With Cells.FormatConditions(Cells.FormatConditions.Count) .DupeUnique = xlDuplicate .Interior.Color = RGB(255, 0, 0) End With If MsgBox("Red highlighted cells are duplicated. OK to remove duplicates?", vbOKCancel) = vbOK Then Cells.RemoveDuplicates Columns:=Array(1), Header:=xlNo Range("A65536").End(xlUp).Offset(1, 0).Select End If Cells.FormatConditions(Cells.FormatConditions.Count).Delete 

结束小组