Delete non duplicate rows

christianbiker

Active Member
Joined
Feb 3, 2006
Messages
365
Greetings folks,

I have a spreadsheet that contains many rows of data. Some of the cell values in column A are duplicates while others are unique and there is only 1. I would like to use VBA to delete the rows that contain unique values in column A, while leaving the duplicate values (+ their corresponding rows) found in column A.

Any assistance would be greatly appreciated.

C
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Glad you sorted it & thanks for the feedback.
 
Upvote 0
Fluff...you have been very helpful and I've asked lots of questions...

Along the line of duplicates, I have found the following code that uses specific colours to highlight duplicates. Is there a way to apply it to a range such as A2:D150?

VBA Code:
Dim a, i As Long
a = Range("A2", Range("a" & Rows.Count).End(xlUp)).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For i = 1 To UBound(a, 1)
    If Not IsEmpty(a(i, 1)) Then
        If Not .exists(a(i, 1)) Then .Item(a(i, 1)) = VBA.Array("", 0)
        w = .Item(a(i, 1))
        w(0) = w(0) & IIf(w(0) = "", "", ",") & Cells(i, 1).Address(0, 0)
        w(1) = w(1) + 1: .Item(a(i, 1)) = w
    End If
Next
For Each e In .items
    If e(1) <> 1 Then
        Select Case e(1)
            Case 2: myClr = vbYellow
            Case 3: myClr = vbRed
            Case 4: myClr = vbBlue
            Case 5: myClr = vbMagenta
            Case 6: myClr = vbGreen
            Case Else: myClr = vbCyan
        End Select
        Range(e(0)).Interior.Color = myClr
    End If
Next
End With
 
Upvote 0
As this is now a totally different question, please start a new thread.
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top