+ Reply to Thread
Results 1 to 20 of 20

Deleting Duplicate Rows with vba

  1. #1
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Deleting Duplicate Rows with vba

    Hi, Jaslake,
    Here are the additional files you requested. I appreciate all your help.
    Lin

    I think I deleted my original post when adding new documents. Here was the original post:

    Hi, I have this worksheet that I have VBA to consolidate 14 logbooks into this one master logbook (attached). You can view the code there if needed.
    On Sheet 1 I have made two buttons. One is called "Reorder Date of Hearing" and the other is "Consolidate Logbooks." Both of these work fine.

    I would like to add a third button to delete duplicate rows once I consolidate the logbooks. I am having trouble finding this code on line and adapting it to my needs.

    Hope someone can help.

    Each row could have duplicate dates, board numbers and employees, etc. That's okay. But when I consolidate the logbooks on a continual basis, the previous info in the logbooks then gets dumped into the master logbook creating duplicates. Hope that makes sense. In other words, my vba code doesn't add only NEW data to the master logbook as each logbook is updated. The vba takes the old and new data and consolidates it all over again and adding on to the previous data in the master logbook.

    I guess I have two options:
    1) write another vba to find the duplicates that were added on which I can’t seem to figure out
    2) add vba to the already "consolidated logbooks" button to only add new data from the 14 logbooks. Then I am wondering how if changes were made to existing info how that would transferred to the master logbook? This I also don’t know how to do.

    Ughh. I am very new to this and have made this worksheet by googling and youtube so hopefully someone can help me with this
    Any help would be appreciated.
    Lin
    Attached Files Attached Files
    Last edited by Scrapnforfun; 01-08-2017 at 09:50 PM. Reason: Additional Documents Requested

  2. #2
    Banned User!
    Join Date
    03-06-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    295

    Re: Deleting Duplicate Rows with vba

    I found this code to remove duplicates:

    Please Login or Register  to view this content.

  3. #3
    Banned User!
    Join Date
    03-06-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    295

    Re: Deleting Duplicate Rows with vba

    The whole row can be deleted with a loop:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    I found this code, too. It works great but it is based on only duplicates in Column A. I would need it to apply across all my rows up to M because sometimes I have the same board number and employee but the other data is different.
    Do you have any idea what part of this code I should change to incorporate all columns?
    That's where I get lost. And maybe it doesn't even apply to this formula.
    Thanks for all your help. I hope you have an answer
    Lin

  5. #5
    Banned User!
    Join Date
    03-06-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    295

    Re: Deleting Duplicate Rows with vba

    Maybe try this instead and adapt to your specific columns and range:

    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: Deleting Duplicate Rows with vba

    Hi Scrapnforfun

    The way I usually approach this issue (prevent posting previously processed Data) is to add a Column to each of the 14 Log Books. Label the Column "Processed".

    In your Code, as each individual Log Book is processed...
    • Place an "X" in this "Processed" Column.
    • Filter on this "Processed" Column for "Blanks"; process only those Filtered Rows.
    It's pretty straight forward.

    If you need help with the Code add a couple of individual Log Books (with Data) to your Thread...one of us will assist.
    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.

  7. #7
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    Hi, Jaslake,
    I am not quite sure I am following you. Sorry.

    I have added four dummy files and the master and also added the "Processed" column in all workbooks, including the master where I would like all the workbooks added to. I needed to take out duplicates based on the full row because some of the data in the worksheets are all the same except sporadic different cells (hope that makes sense).

    Do you think you could help me with the code and take a look at the code that I have? I made two buttons, one to consolidate the workbooks into the master and also to reorder the "Date of Hearing" column as we sometimes add hearings with an older date after a more current date. Also, the "Notes" column may be left blank as there may not be a note to add in there.

    When I hit the "Consolidate" button, it will take all logbooks and add them to the master, but when you hit it again, it will just add in the same info even if there wasn't a change made to the worksheet.

    I hope I gave you enough information and it makes sense. I am rather new to this and just keep trying codes til they work. I have some understanding but still have a lot to learn

    I can add the other worksheets to my original post.
    Thanks for all your help. I have been working on this for days and days. It seems like forever
    Lin

  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: Deleting Duplicate Rows with vba

    Hi Scrapnforfun

    No need to apologize...you don't need to follow yet...you will eventually.

    I must ask...why is there Code in all the Workbooks? Seems there should be Code only in Workbook Logbook Master.xlsm.
    I'm going to pursue this for a bit tonight...have an appointment in the AM. I THINK I understand what you're trying to accomplish...get back to you in a bit.

  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: Deleting Duplicate Rows with vba

    Hi Lin

    We'll fix it...won't be tonight...gotta get to bed...stuff in the AM...

  10. #10
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    Hi,
    Sorry I didn't reply back last night. My daughter had something going on I needed to help her with.
    I appreciate any help you can give whenever I have been working on this for days, full days so it is much appreciated.
    I have code in all workbooks for the button "Reorder Hearing Date." When we enter files individually, we may enter them out of date sequence so I have the code to reorder the hearing date from past to current.

    Then the master logbook has that same code so when I then combine all the workbooks, the master logbook can reorder the hearing dates from all the individual logbooks. The master logbook also has the code to now combine all these logbooks. So that's two codes for the master logbook and one code for each individual logbook. If there is any other code or modules, that's because I was trying to fiddle around and figure out how to get rid of duplicates. My "Remove Duplicates" button does not work in my version of 2010. Once in a while it will but then doesn't, so I don't trust it. That's why I have this dilemma in trying to either get another vba code in there to delete duplicates or add to the existing master logbook code with maybe something that will only add in new data from each logbook.

    Maybe my code in the master logbook can be expounded upon to just add in new transferred data from each individual logbook. I don't know. That's beyond me.

    Thanks again. Have a successful appointment today!
    Lin

    PS: There may be an easier solution to accomplish all this, but with my inexperience, I may have made this more complicated. I have so say, though, all the help on this forum and videos is what got me to this point, and I appreciate all that have helped me!!!
    Last edited by Scrapnforfun; 01-09-2017 at 06:20 AM.

  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: Deleting Duplicate Rows with vba

    Hi Lin

    This Code in the attached assumes the Log Book Master and the 14 individual Log Books are in the same Folder...matters not where.
    If this is not the case let me know.

    The Code will open each individual Log Book and populate Log Book Master with the "Unprocessed" items from the individual Log Books.

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

  12. #12
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    JasLake,
    You are a GENIOUS!
    Exactly what I needed. It works perfectly. Just one question. Does that also update if someone were to make a change to something that was already "processed"? Say they changed a date or misspelled the person's name and corrected it. Would that correction then get changed on the master?

    Thanks again for all your help. I can't believe you did it! I would never have been able to write that whole code. Thanks again. You accomplished something that took me days to do (or not do).

    Lin

  13. #13
    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: Deleting Duplicate Rows with vba

    Hi Lin

    In a word...No...that's a completely different process.
    Does that also update if someone were to make a change to something that was already "processed"? Say they changed a date or misspelled the person's name and corrected it. Would that correction then get changed on the master?

  14. #14
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    I thought as much. You're still the best!
    Thanks again for all your help. I'll add my rep for you. If I could give ten stars, you'd have them
    Lin

  15. #15
    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: Deleting Duplicate Rows with vba

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

  16. #16
    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: Deleting Duplicate Rows with vba

    Hi Lin

    The only way to do this that comes to mind given your File Structure and the number of Files involved would be to create a Cross Reference between the Master and the individual Log Books at such time as records are processed. Were the User to change a record on the individual Log Book the "X" would get cleared and the record would get replaced in the Master by the changed individual Log File record. All a bit messy...and requires discipline...

    If you're interested create a new Thread for this issue...PM me with a Link if you wish.

  17. #17
    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: Deleting Duplicate Rows with vba

    Hi Lin

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

  18. #18
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    Hi Jaslake,
    I was hoping you could help a little more with this spreadsheet. I've been using it for a bit and it is great except if a half a line was filled in on the individual logbook and then they come back a few days later and finish filling in the same line but it was "processed" before they came back to finish the line, is there any way to have the rest of the data entered transfered to the master logbook when I hit the "consolidate logbooks" button? It is just that I would like to use the logbook master as the go-to logbook, and I wouldn't know if someone changed something or added to a line in their individual logbook once it is processed because it won't show up in the logbook master. Is this doable? I really appreciate it if you could help me again.
    Thanks.
    Lin

  19. #19
    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: Deleting Duplicate Rows with vba

    Hi Lin

    Seems we discussed this same issue in responses 12-16...is it different?

    I was hoping you could help a little more with this spreadsheet. I've been using it for a bit and it is great except if a half a line was filled in on the individual logbook and then they come back a few days later and finish filling in the same line but it was "processed" before they came back to finish the line, is there any way to have the rest of the data entered transfered to the master logbook when I hit the "consolidate logbooks" button? It is just that I would like to use the logbook master as the go-to logbook, and I wouldn't know if someone changed something or added to a line in their individual logbook once it is processed because it won't show up in the logbook master. Is this doable?

    My response to you at that time was...
    The only way to do this that comes to mind given your File Structure and the number of Files involved would be to create a Cross Reference between the Master and the individual Log Books at such time as records are processed. Were the User to change a record on the individual Log Book the "X" would get cleared and the record would get replaced in the Master by the changed individual Log File record. All a bit messy...and requires discipline...
    If the same issue as described you'll need to start a new Thread...

  20. #20
    Registered User
    Join Date
    05-02-2016
    Location
    Massachusetts
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Duplicate Rows with vba

    I'm sorry. I must have missed that response. I read the one with the "short answer is no." When I create a new thread, would I put the same spreadsheets in the with the question which is actually your response? I guess I don't understand what you mean by "a bit messy and requiring discipline." Discipline on the part of the person using the individual logbook or the person using the master workbook?
    Would you mind responding on how I should start this thread. I'd appreciate it.
    Thanks so much for your help.
    Lin

+ 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. Code for Eliminating duplicate rows and re arrange without deleting rows
    By pvsvprasad in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-21-2016, 02:42 PM
  2. [SOLVED] Deleting Duplicate Rows???
    By jerickson in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-27-2012, 01:02 PM
  3. Deleting duplicate rows
    By PBANKS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2008, 03:57 PM
  4. Need Help with Deleting Duplicate rows
    By japorms in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2006, 01:25 PM
  5. Deleting duplicate rows
    By vanessa h in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2006, 08:26 AM
  6. Deleting Duplicate Rows
    By pettes01 in forum Excel General
    Replies: 4
    Last Post: 11-08-2005, 02:55 PM
  7. Deleting Duplicate Rows
    By RMort in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-26-2005, 05: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