+ Reply to Thread
Results 1 to 11 of 11

Remove duplicates when copying a row from one sheet to another

  1. #1
    Registered User
    Join Date
    02-03-2016
    Location
    USA
    MS-Off Ver
    office 2007
    Posts
    7

    Post Remove duplicates when copying a row from one sheet to another

    Hello,

    I am new to the wonderful world of VBA. I have a mastersheet with data that once updated a user can click the "update" button and the info transfers over to the corresponding sheet. However, when the button is clicked for the 2nd, 3rd, 4th, etc. time, the data duplicates previous data already copied to the additional sheets. I know that I am needing to delete the duplicates, but nothing I have tried so far is working. Help!

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Remove duplicates when copying a row from one sheet to another

    Hi JTH2016 and Welcome to the Forum!!!

    I don't know...I looked all over for the Update Button and couldn't find it nor any Code associated with it. Did you attach the correct File?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    02-03-2016
    Location
    USA
    MS-Off Ver
    office 2007
    Posts
    7

    Re: Remove duplicates when copying a row from one sheet to another

    Hi John,

    Thanks for responding. The button is on the "Requestes" sheet around column U1. When I open the attached file, I do show the code but...

    This is the code I am working with:

    Sub As_Of_Analysis_Sorting()
    Dim lr As Long, lr2 As Long, r As Long
    lr = Sheets("Requests").Cells(Rows.Count, "A").End(xlUp).Row
    lr2 = Sheets("Jan").Cells(Rows.Count, "A").End(xlUp).Row
    lr3 = Sheets("Feb").Cells(Rows.Count, "A").End(xlUp).Row
    lr4 = Sheets("Oct").Cells(Rows.Count, "A").End(xlUp).Row
    For r = lr To 3 Step -1

    If Range("t" & r).Value = "Jan 16" Then
    Rows(r).Copy Destination:=Sheets("Jan").Range("A" & lr2 + 1)
    lr2 = Sheets("Jan").Cells(Rows.Count, "A").End(xlUp).Offset(0, 0).Row
    End If
    If Range("t" & r).Value = "Feb 16" Then
    Rows(r).Copy Destination:=Sheets("Feb").Range("A" & lr3 + 1)
    lr3 = Sheets("Feb").Cells(Rows.Count, "A").End(xlUp).Offset(0, 0).Row
    End If
    If Range("t" & r).Value = "Oct 16" Then
    Rows(r).Copy Destination:=Sheets("Oct").Range("A" & lr4 + 1)
    lr4 = Sheets("Oct").Cells(Rows.Count, "A").End(xlUp).Offset(0, 0).Row
    End If
    Range("A1").Select
    Next r
    Application.ScreenUpdating = True
    End Sub


    Any help is greatly appreciated!

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Remove duplicates when copying a row from one sheet to another

    Sorry, I missed the Button. Please wrap any Code you publish in Code Tags.

    I'll look at this...

  5. #5
    Registered User
    Join Date
    02-03-2016
    Location
    USA
    MS-Off Ver
    office 2007
    Posts
    7

    Re: Remove duplicates when copying a row from one sheet to another

    Sorry about that. Really new to this.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Remove duplicates when copying a row from one sheet to another

    Hi JTH2016

    How, why and when does Column L get populated?

  7. #7
    Registered User
    Join Date
    02-03-2016
    Location
    USA
    MS-Off Ver
    office 2007
    Posts
    7

    Re: Remove duplicates when copying a row from one sheet to another

    Hi John,

    Column L is updated by the user. It is simply a column to track when the incoming requests are sent on for additional processing. In the example, my intent was to show that if you use anything other than "x" it will not track as required. Hope this helps.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Remove duplicates when copying a row from one sheet to another

    Hi JTH2016

    Hold off...forgot to put in error checking.
    Last edited by jaslake; 02-10-2016 at 12:44 PM.

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Remove duplicates when copying a row from one sheet to another

    Hi JTH2016

    This Code is in the attached and appears to do as you require. Please note, I've added Column U to track transferred data.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-03-2016
    Location
    USA
    MS-Off Ver
    office 2007
    Posts
    7

    Re: Remove duplicates when copying a row from one sheet to another

    John,

    You are a lifesaver!!! It works great. Thanks for all your help..and patience.

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Remove duplicates when copying a row from one sheet to another

    You're welcome...glad I could help. Thanks for the Rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. Need macro to remove duplicates from excel sheet after adding the contents
    By Amruta_chintalwar in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-19-2014, 06:43 PM
  2. Macro that would Copy/Paste to new sheet and remove duplicates
    By dani_n88 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-11-2012, 06:04 PM
  3. [SOLVED] Remove duplicates in whole sheet
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2012, 07:31 AM
  4. [SOLVED] Identify duplicates and remove both from sheet.
    By markDuffy in forum Excel General
    Replies: 2
    Last Post: 05-30-2012, 12:09 PM
  5. Replies: 5
    Last Post: 07-25-2011, 09:42 PM
  6. Copy Entire Row into New Sheet, remove duplicates
    By aeh7b in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-17-2011, 05:46 PM
  7. Trying to run a macro to sort and remove duplicates from entire sheet
    By sgmiller in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2009, 10:24 AM

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