Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

Duplicate rows in excel

Please look at the attached duplicatesexamplea.xls.

I need to identify any duplicates in Sheet1 column B.  My result should look like Sheet2.

How can I do this?

duplicatesexamplea.xls
0
EEuser5551212
Asked:
EEuser5551212
1 Solution
 
StephenJRCommented:
A macro solution:
Sub x()

Dim r1 As Range, r2 As Range

With Sheets("Sheet1")
    Set r1 = .Range("B1", .Range("B1").End(xlDown))
    For Each r2 In r1
        If WorksheetFunction.CountIf(r1, r2) > 1 Then
            Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp)(2).Resize(, 2).Value = r2.Offset(, -1).Resize(, 2).Value
        End If
    Next r2
End With

End Sub

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now