+ Reply to Thread
Results 1 to 14 of 14

Deleting matching rows from different excel sheets

  1. #1
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Deleting matching rows from different excel sheets

    Twice a month I have to pull a report to check for additions or deletions to our tracker. I have been doing this manually for months and I have tried to think of a way to have excel do this for me but I cant seem to make anything work. The report has numerous coumns and the number of rows vary every report. An example of the data is:
    Name SSN Course Date
    John 1234 Blah1 1/13/2013
    Jim 2345 Blah2 2/13/2013
    James 3456 Blah3 3/13/2013
    There are more columns, but what I want to do is find the data in rows X through X that matches data in rows Y through Y and delete the data in row Y that matches row X. That way when I pull the report and add it to the bottom of my current sheet I can run the script and won't have to go line by line to check for changes. I'm sorry if this isn't clear and I can give more information based on what is needed. If easier, I can also pull the new report into a new sheet and then have the script compare cells from one sheet to another. I can't add the actual excel sheet due to security. I know there are excel guru's on here that can make my life easier. Any ideas and what else do you need? Thank you in advance!

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Deleting matching rows from different excel sheets

    There is one way you can do this -

    If you 2 or more sheets that need to be compared with each other - we can consolidate all the data from each sheet into one new tab with one column giving the sheet name from where the data came from.
    Clear the data in all the sheets except this newly consolidated sheet.
    Compare line by line using some unique identifier column(s) and the column containing the sheet name.
    Delete the duplicates.
    Reload the data from the consolidated sheet into the other sheets based on the column containing the sheet name.
    Delete the consolidated sheet.

    Would this work for you?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    Yes, though I have no idea about the logical sequence to perform those tasks. Your breakdown seems very clear and will perform the required tasks with the appropriate product. Thank you for your prompt response and I am hopeful that with your help I will be able to make this tedious task mush simpler. I love excel and I wish I had the knowledge some of the users on this site have.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Deleting matching rows from different excel sheets

    Please upload a sample file which has the exact format as the original.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  5. #5
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    Report Example.xlsx
    Alright here is an example of what the data sheet looks like. The column headings in the table are the same. I have removed all data from the table and changed the sheet name. The hidden columns are information that isn't needed and are always hidden in my reports.
    Last edited by cnash52; 03-15-2013 at 08:04 AM.

  6. #6
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    Did the attachment work?

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Deleting matching rows from different excel sheets

    Yes it did. But you need to put data in it. I wouldnt be able to test the code without it.

  8. #8
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    Report Example.xlsx
    I tried updating the old upload but apparently it didn't upload the correct data.

  9. #9
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    I am starting to lose hope that I will get resolution. I haven't heard back since I uploaded the sheet with data in it.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Deleting matching rows from different excel sheets

    Sorry for the delay in getting back to you.

    You had mentioned that 2 different sheets need to be compared to each other right? But your file in post 8 has only 1 sheet of data.

    Also, which are the fields which need to be compared to ascertain if the row is a duplicate?

  11. #11
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    Report Example.xlsx
    I have duplicated the first sheet to the second sheet and modified a few of the cells in column P. If the code compared rows B, P, and V and deleted the rows that contained the same information in those three cells from the orginal sheet I believe it would work accurately. If the code could compare those three cells and follow the process you listed in the begining of our discussion it would be amazing. Thank you for your response.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Deleting matching rows from different excel sheets

    The attached code deletes the match rows from the original sheet
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Deleting matching rows from different excel sheets

    The attached code did in fact work to delete the matching rows. I modified it slightly to fit my Sheet names and it works perfectly. There are some additional tasks I want the code to do which I will try to figure out as I have an idea how to get them to work. Thank you arlu1201 and AB33 for your assistance. It is GREATLY appreciated. I will continue to come back to this site for code questions I have in the future and I am definately adding to both of your reputations.

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Deleting matching rows from different excel sheets

    Thank you...glad its solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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