Solved

Duplicate rows in excel

Posted on 2011-02-15
2
343 Views
Last Modified: 2012-05-11
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
Comment
Question by:EEuser5551212
2 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 250 total points
ID: 34897565
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
 
LVL 7

Expert Comment

by:twol
ID: 34897617
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question