Hello group! In a earlier post I had sought help trying to delete any duplicate info if there was a duplicate number in column V and have it delete the last entry row. With help from this site I was able to get that to work. The problem that I've since discovered is that I need to really look at the duplicate numbers to see what row of the duplicates that I would prefer to keep before deleting any of them; due to content entry if slightly different, etc. Thus my new request for help!
What I'd like to do is have help with the following code or new code if possible which will allow me to identify the duplicate numbers in column "V" and have them appear in a message window. The code would search the entire column of data and afterwards pop up a message window that would say something to the effect "The following complaint #'s have duplicate entries: 454,462,527,..." etc.
Then I would be able to manually filter those numbers and delete the row(s) I choose.
The following code currently identifies the number of duplicate entries in column "V" and deletes the 2nd entry in Column "V" only (not the entire row). Afterwards a message window will appear notifying me something to the effect "There were 10 duplicate entries deleted". Would anyone be able to help modify this code to just identify the duplicate entry numbers instead of deleting anything?
Any help would be appreciated.
Sub DeleteDuplicateEntries() Dim rClMain As Range Dim rClDupe As Range Dim rCheck Dim N As Long Dim LR As Long, i As Long, found As Range Application.ScreenUpdating = False N = 0 'currently starts in A6 down,adjust to your data Set rCheck = Range(Cells(6, 22), Cells(Rows.Count, 22).End(xlUp)) For Each rClMain In rCheck '1st loop - (to speed things up ignore any empty cells) If rClMain <> Empty Then For Each rClDupe In rCheck '2nd loop - compare non-empty rClDupe values 'and clear contents if it's a duplicated value If rClDupe <> Empty And _ rClDupe.Value = rClMain.Value And _ rClDupe.address <> rClMain.address Then rClDupe.ClearContents N = N + 1 End If Next rClDupe End If Next Application.ScreenUpdating = True MsgBox "There were " & N & " duplicated entries deleted" End Sub
Last edited by lilsnoop; 01-27-2012 at 06:51 AM.
Maybe:
Option Explicit Sub DeleteDuplicateEntries() Dim rClMain As Range Dim rClDupe As Range Dim rCheck Dim N As Long Dim LR As Long, i As Long, found As Range Application.ScreenUpdating = False N = 0 'currently starts in A6 down,adjust to your data Set rCheck = Range(Cells(6, 22), Cells(Rows.Count, 22).End(xlUp)) For Each rClMain In rCheck '1st loop - (to speed things up ignore any empty cells) If rClMain <> Empty Then For Each rClDupe In rCheck '2nd loop - compare non-empty rClDupe values 'and clear contents if it's a duplicated value If rClDupe <> Empty And _ rClDupe.Value = rClMain.Value And _ rClDupe.Address <> rClMain.Address Then 'rClDupe.ClearContents Dim SummaryList As String SummaryList = SummaryList & rClDupe.Value & vbTab & rClDupe.Address(0, 0) & vbCrLf N = N + 1 End If Next rClDupe End If Next rClMain Application.ScreenUpdating = True MsgBox "There were " & N & " duplicated entries found" & vbCrLf & SummaryList End Sub
---
Ben Van Johnson
Thanks so much protonLeah! Your revision worked perfectly!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks