+ Reply to Thread
Results 1 to 5 of 5

find all duplicate entries and copy to another sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    find all duplicate entries and copy to another sheet

    hi guys, I have searched and copied different pieces of code but just seem to get myself more confused, what I need is, see below, I would like some vba code that can check column E for duplicates and then copy those rows to sheet3, so looking at the below, column E (5), the code needs to identify 1111 in rows, 1,4,7,9 and rows 2,5 (2345), and any others, and then copy these rows to sheet3, any help would be appreciated

    scouse13

    Sheet2
    KKS
    A B C D E F G H ETC
    1 NO 1234 YRT DPK 1111 RTG YES NO
    2 2345
    3 27654
    4 1111
    5 2345
    6 09864
    7 1111
    8 5748
    9 1111
    10 0286

  2. #2
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: find all duplicate entries and copy to another sheet

    sorry the formatting seemed to change when posted? all the numbers are column E
    Last edited by AliGW; 02-22-2020 at 06:36 AM. Reason: Please don't quote unnecessarily!

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: find all duplicate entries and copy to another sheet

    How about
    Sub scouse13()
       Dim Cl As Range, Rng As Range
       Dim Dic As Object
       
       Set Dic = CreateObject("scripting.dictionary")
       With Sheets("Sheet1")
          For Each Cl In Range("E2", .Range("E" & Rows.Count).End(xlUp))
             If Not Dic.Exists(Cl.Value) Then
                Dic.Add Cl.Value, Cl
             Else
                If Rng Is Nothing Then Set Rng = Union(Cl, Dic.Item(Cl.Value)) Else Set Rng = Union(Rng, Cl, Dic.Item(Cl.Value))
             End If
          Next Cl
       End With
       If Not Rng Is Nothing Then Rng.EntireRow.Copy Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End Sub
    Change sheet names to suit

  4. #4
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: find all duplicate entries and copy to another sheet

    Hi Fluff13, thanks for your help, tried the code you supplied with some dummy numbers, I put 10 rows of figures in, three were the same 12459, and another 2 two were 2345, when running the code only 2 of the 12459 were picked up and none of the 2345?, any ideas

    scouse13
    Last edited by AliGW; 02-22-2020 at 06:36 AM. Reason: Please don't quote unnecessarily!

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: find all duplicate entries and copy to another sheet

    Can you post your test file?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find duplicate cells, copy and paste it into new sheet (plus sum of values)
    By josemtzdlr in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-13-2019, 12:49 PM
  2. Find duplicate entries in different ranges
    By rosshkerr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2018, 08:53 AM
  3. [SOLVED] Find Duplicate name in 3 sheets, copy certain cells to a spefic location in 4th sheet
    By Jim9_1100 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-16-2012, 06:29 PM
  4. Find match for different entries and copy row to new sheet
    By Maki2012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2012, 01:34 AM
  5. How to find duplicate entries, find which has the lowest value, and delete the rest?
    By John2810 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-05-2011, 06:39 AM
  6. [SOLVED] Programatically find Duplicate entries
    By Steph in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2005, 02:06 PM
  7. Find duplicate entries
    By kharrison in forum Excel General
    Replies: 4
    Last Post: 02-24-2005, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1