+ Reply to Thread
Results 1 to 9 of 9

Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

  1. #1
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Question Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi All,

    I would like some help generating some code to do the following:

    I have two sheets in a workbook 1) "Comments", 2) "Tracker"

    The "Comments" sheet is populated by another worksheet. I require the "Tracker" sheet to be populated from the "Comments" sheet which will vary and be updated itself everytime the worksheet opens or closes.
    The macro needs to copy all the lines of data from "Comments" sheet to "Tracker" sheet. The data consists of the 6 columns below.
    1. Item
    2. Group
    3. Person
    4. Comment
    5. Rating 1
    6. Rating 2

    Item & Group columns are fixed values and the remaining 4 columns vary.

    The macro needs to cross-reference data in the "Comments" & "Tracker" sheets. If the row item values for Item and Group occur in both sheets, ensure, for that row that the remaining columns 3 to 6 are up-to-date (My idea was to search for the Combinations of Item & Group row data in the "Comments" sheet and if they were found in the "Tracker" sheet, copy the remaining 4 columns of data for that row and paste it behind the found Item & Group combo in the "Tracker" sheet.)

    If the Item & Group values for a given row are NOT in both spreadsheets, copy the complete line from "Comments" to "Tracker".

    Finally a reverse cross-reference whereby if items that have been previously copied & placed in the "Tracker" sheet are no longer present in the "Comments" sheet - Select that row of data in the "Tracker" sheet and go to the next available column and put "Void".

    I have populated a sample workbook. You will see that Items 'I5' & 'I9' have been removed in the comments sheet and thus are now marked as void in the Tracker sheet.

    In essence this will keep track of present and past comments, keeping current comments up to date and voiding old comments.

    I realise this is quite a job but any help would be appreciated as always!
    Cheers,
    Mark
    Attached Files Attached Files
    Last edited by R_S_6; 10-18-2010 at 04:04 AM.

  2. #2
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Question Re: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Any one have any ideas?
    Cheers,
    Mark

  3. #3
    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: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi Mark

    I've some ideas; I'll play with it tonight.

    John
    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.

  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: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi Mark

    This code is in the attached workbook
    Please Login or Register  to view this content.
    It appears to do as requested.

    Let me know of issues.

    John
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Re: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi John,

    Thank you so much for that!

    Your code does pretty much everything - the one thing it doesn't do is update the Tracker sheet if a new row is added to the Comment sheet. Also as a start point the Tracker document will be blank and will first have to be populated by the comment sheet including the titles in Row 1.

    I have had a play with the rest of the functionality and it works perfectly!
    If you delete a row in the comment sheet it voids it in the Tracker sheet.
    If you modify columns 3 to 6 in the comments sheet it updates these in the Tracker Sheet!

    I have had a play with the code and I sort of have it working. (To populate the Tracker sheet in the first instance and copy new rows from the comments sheet if they have been added)
    However when run the first time, it ignores the Titles in the tracker sheet, Then on the second run it puts in the titles but moves what was the first data set 'G1' to near the bottom of the rows of data??? Think it has something to do with the 'tLR = tLR + 1' step in my code. I changed the "A2" references to "A1" references in the hope to copy across the titles...

    Here's the code:

    Please Login or Register  to view this content.
    Can you have a look when you get a chance?
    Thanks so much for the work you have done so far - Its very much appreciated!
    Cheers,
    Mark

  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: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi Mark



    I need some clarification.
    ... as a start point the Tracker document will be blank and will first have to be populated by the comment sheet including the titles in Row 1
    I understand this as a first run. Then, on subsequent runs, if "Tracker" is populated, the procedure should:
    1. Add new items from "Comments" to "Tracker"
    2. Change "Tracker" if "Comments" has changed
    3. Mark "Tracker" records "void" if no longer on "Comments"
    My initial reaction is:
    1. If Sheet "Tracker" doesn't exist, create it and copy Sheets "Comments" to Sheet "Tracker"
    2. Run the procedure to do the Concatenation, Compare and Cross Compare.
    3. On the initial run, the two Worksheets will be exactly the same.
    I sense I'm missing something.

    John

  7. #7
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Re: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi John,

    Thanks for your post. The "Comments" sheet is populated by a spreadsheet that contains data in defined fields but it is a fluid document. Thus the "Comments" sheet will be updated by external data everytime the sheet is opened. What I don't want to do is loose old items - A history almost of the comments.

    Here are the steps as I see them:

    1. If Tracker doesn't Exist - Create it and copy all data from "Comments" to "Tracker". (Code can finish here if the "Tracker" sheet didn't originally exist.)
    2. At the click of a user, check that the "Tracker" sheet exists. If it does exist, check that it is up-to-date with details from the "Comment" sheet:
    * 2A. If new line items have been added to "Comments" - copy these to "Tracker"
    * 2B. If the Row items (Starting with Item & Group) in "Comments" are found in "Tracker", update the remaining 4 columns for each applicable row.
    * 2C. If the Row items in "tracker" are no longer found in "Comments" - Mark as Void in last column of "Tracker" sheet against the applicable row item.

    Hopefully that more clearly depicts the process - Sorry its quite hard to put the process into words :-)

    Let me know if you have further questions. Thanks so much!
    Cheers,
    Mark

  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: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi Mark

    Try the code in the attached file.

    Let me know of issues.

    John
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Re: Compare two Sheets - Add New Data, Update Differences, Highlight Void Data

    Hi John,

    That's Fantastic! It does absolutely everything I need it to and does all that perfectly! Thanks so0 much for your help!!!

    Cheers,
    Mark

+ 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