+ Reply to Thread
Results 1 to 17 of 17

Macro: Move Duplicate Rows From One Worksheet To Another

Hybrid View

  1. #1
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Macro: Move Duplicate Rows From One Worksheet To Another

    Try this
    Sub test()
        Dim dic As Object, i As Long, x As Range
        Set dic = CreateObject("Scripting.Dictionary")
        dic.CompareMode = 1
        With Sheets("sheet1").Cells(1).CurrentRegion
            For i = 2 To .Rows.Count
                If Not dic.exists(.Cells(i, 1).Value) Then
                    dic(.Cells(i, 1).Value) = Empty
                Else
                    If x Is Nothing Then
                        Set x = .Rows(i)
                    Else
                        Set x = Union(x, .Rows(i))
                    End If
                End If
            Next
            If Not x Is Nothing Then
                Union(.Rows(1), x).Copy Sheets("sheet2").Cells(1)
                x.EntireRow.Delete
            End If
        End With
    End Sub

  2. #2
    Registered User
    Join Date
    07-04-2014
    Location
    Conroe, TX
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    11

    Re: Macro: Move Duplicate Rows From One Worksheet To Another

    Quote Originally Posted by jindon View Post
    Try this
    ...
    Thank you, that is much closer to what I am trying to do;
    however, if you compare the result produced by your function
    to the desired result that I uploaded as Workbook2, you will
    see that they are not quite the same.

  3. #3
    Registered User
    Join Date
    07-04-2014
    Location
    Conroe, TX
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    11

    Re: Macro: Move Duplicate Rows From One Worksheet To Another

    Perhaps I did not make it clear, but a row should be considered
    to be a duplicate only if it is identical, in every column, to some
    other row.

+ 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] Move rows with duplicate values in column J to next worksheet
    By theletterh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2013, 10:38 AM
  2. Macro to move rows with specific content to another worksheet
    By Bobbington in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2012, 11:05 AM
  3. Macro to move specific rows from one worksheet to another
    By LaughingLaurie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2012, 02:33 PM
  4. Replies: 1
    Last Post: 02-11-2012, 11:15 AM
  5. move duplicate rows to another worksheet
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-06-2009, 07:36 PM

Tags for this Thread

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