+ Reply to Thread
Results 1 to 6 of 6

Copy/Paste Remove Duplicates

Hybrid View

  1. #1
    Registered User
    Join Date
    10-22-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    80

    Cool Copy/Paste Remove Duplicates

    Hi all again. I need help on the following code

    Private Sub CommandButton2_Click()
        Workbooks.Open ("D:\Book2.xlsx")
        Application.Goto Reference:="Table1"
        Selection.ClearContents    Windows("Book1.xlsm").Activate
        Range("Table1").Select
        Selection.Copy
        Windows("Book2.xlsx").Activate
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        ActiveWorkbook.Save
        ActiveWindow.Close
    End Sub
    Instead of the "Clearcontent" in the code above in red.
    I need help on a code that will remove all the duplicate lines in the end.

    So it copy/paste and the check for duplicate lines and remove them save

    Private Sub CommandButton2_Click()
        Workbooks.Open ("D:\Book2.xlsx")
        Windows("Book1.xlsm").Activate
        Range("Table1").Select
        Selection.Copy
        Windows("Book2.xlsx").Activate
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        Somewhere Over here should be that line i think
        ActiveWorkbook.Save
        ActiveWindow.Close
    End Sub
    Thanks in advance
    Last edited by Rage; 11-10-2009 at 10:04 AM.

  2. #2
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: Copy/Paste Remove Duplicates

    Why can't you use the 'Remove duplicates' option of Excel 2007 or 'Advance Filter -> Uniques Records Only' option of previous excel versions to remove duplicates? Or if it is to do it only thru macro then I think using dynamic arrays may help.

  3. #3
    Registered User
    Join Date
    10-22-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Copy/Paste Remove Duplicates

    Yes it is to do only trough the macros.
    As for arrays... ah... :P i have no idea how to

  4. #4
    Registered User
    Join Date
    10-22-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    80

    Unhappy Re: Copy/Paste Remove Duplicates

    Helpeeee please

  5. #5
    Registered User
    Join Date
    10-22-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Copy/Paste Remove Duplicates

    Ok after thinking a bit, i need the code to add up to my other sheet instead of clearing the contents.

    Any help would be welcome.

  6. #6
    Registered User
    Join Date
    10-22-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Copy/Paste Remove Duplicates

    Bump, A little help needed. Ty

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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