+ Reply to Thread
Results 1 to 13 of 13

Compare two worksheets and show the differences in two other worksheets....

  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Compare two worksheets and show the differences in two other worksheets....

    Hello

    I am working on a project. I had it in MS Access 2003. My company decided to do away with MS Access. I have to do the same thing in MS Excel 2010.

    My company has three sections 1 Hardware 2 Software 3 Accounting

    And has over 6000 employees working in over 60 countries. For, this example I have used only 10 countries

    36 AU Australia
    156 CN China
    208 DK Denmark
    250 FR France
    356 IN India
    144 LK Sri Lanka
    682 SA Saudi Arabia
    376 IL Israel
    826 GB United Kingdom
    840 US United States Of America

    Continuously people are quitting and new members are joining the company.

    The EID is the only constant in each record.

    I need help with this, please. I want to do it with VBA code.

    First, I want to put all the members who have quit in “QuitMembers” and new members in “NewMembers”

    I have highlighted the quit members in “PreviousFN” and the new members in “CurrentF”

    Regards and thanks

    Raghu
    Attached Files Attached Files
    Last edited by raghuprabhu; 03-25-2017 at 03:34 AM. Reason: finishing

  2. #2
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Compare two worksheets and show the differences in two other worksheets....

    Hi Raghu. If I understand this correctly ...

    You have a list of new & quit members that grows as staff join & leave; these are maintained in QuitMembers and NewMembers.

    You have two sheets - PreviousFN and CurrentFN - with staff who have left highlighted in the PreviousFN sheet and new joiners highlighted in CurrentFN sheet.

    Questions:

    - Is the fact that the whole record is highlighted the only way to determine if they have left or joined?
    - Will other individual cells sometimes be highlighted in records that are not joiners or leavers - as in CurrentFN? (e.g. F2, D4, B5 etc)
    - Noting these two questions - would the EID ever be highlighted as in the 2nd question or can this alone be used to identify leavers / joiners?

    Without putting a button on the sheets, and assuming the file is edited to have the highlighted rows of joiners / leavers, I think using the Worksheet_Deactivate event on PreviousFN & CurrentFN sheets to check for any highlighted rows (or shaded EIN if that is a valid way to ID the joiners & leavers) and copy them if they don't already exist to the QuitMembers & NewMembers sheets respectively.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  3. #3
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Compare two worksheets and show the differences in two other worksheets....

    Hello MatrixMan

    Thank you for your response.

    First of all I want to compare the worksheets and identify Quitters and New comers.

    Answers to your question

    - Is the fact that the whole record is highlighted the only way to determine if they have left or joined?

    No the EID is unique. If a person has quit, then his or her EID will not be in the CurrentFN

    - Will other individual cells sometimes be highlighted in records that are not joiners or leavers - as in CurrentFN? (e.g. F2, D4, B5 etc)

    Similarly the if a new person joins, his or her EID will be absent in the PreviousFN

    - Noting these two questions - would the EID ever be highlighted as in the 2nd question or can this alone be used to identify leavers / joiners?

    EID is the only way to identify leavers and joiners….
    Last edited by raghuprabhu; 03-25-2017 at 05:21 AM. Reason: Make it clear

  4. #4
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Compare two worksheets and show the differences in two other worksheets....

    Ah ... I see ... so PreviousFN and CurrentFN are actually rather large lists of all staff at the point in time they were compiled .. CurrentFN being the most recent. If that's right, then no problem and I'll write some code and send it through shortly.

  5. #5
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Compare two worksheets and show the differences in two other worksheets....

    Thanks MatrixMan....

  6. #6
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Compare two worksheets and show the differences in two other worksheets....

    See attached file. It has the code below called from the Worksheet_Activate events of the QuitMembers and NewMembers sheets.

    This goes in a module:
    Please Login or Register  to view this content.
    And this goes in both the QuitMembers and NewMembers sheet objects:
    Please Login or Register  to view this content.
    Presumably the ChangedMembers one is next ... you should be able to adapt this to check each cell in the row against the previous one to update this with the same event for that sheet. Let me know if you get stuck.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Compare two worksheets and show the differences in two other worksheets....

    Thanks MatrixMan...

    Will try it out and then get back to you.

    The next thing is to copy the common EID from both "PreviousFN" and "CurrentFN' and past them into "ChangedMember"

    There will be two for each member. Sort by EID

    Check to see if any of the five fields are different "Section", "Country", "Surname", "GivenNames" and "PayAmount" for each member.

    If there is no change delete that EID. Finally we will be left EIDs with changed fileds.


    Regards

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,592

    Re: Compare two worksheets and show the differences in two other worksheets....

    AutoFilter
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Compare two worksheets and show the differences in two other worksheets....

    Matrix man and Jindon...

    Thanks to both of you....

    Now I want to put the common records into "ChangedMembers"

    There will be two for each member. Sort by EID

    Check to see if any of the five fields are different "Section", "Country", "Surname", "GivenNames" and "PayAmount" for each member.

    If there is no change delete that EID. Finally we will be left EIDs with changed fileds.


    Regards

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,592

    Re: Compare two worksheets and show the differences in two other worksheets....

    Not really sure though...
    See if this is how you wanted...
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Compare two worksheets and show the differences in two other worksheets....

    Jindon,

    In this,sample I highlighted members who have left and new members for clarity. In the actual files I get around 6000 lines and they are not highlighted.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,592

    Re: Compare two worksheets and show the differences in two other worksheets....

    OK, I see it now.
    This should do... I hope.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    04-27-2012
    Location
    Melbourne, Oz
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Compare two worksheets and show the differences in two other worksheets....

    Matrix Man and Jindon,

    Thanks gentlemen. I consider this as solved.

    Both of you have been terrific.

+ 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. [SOLVED] Compare two worksheets and present differences in a third
    By olivierpbeland in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-28-2013, 03:14 PM
  2. [SOLVED] Compare two worksheets and highlight differences on one of the worksheets
    By Phil Payne in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-18-2013, 04:00 AM
  3. Compare 2 worksheets for differences
    By MikeWinn in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-31-2013, 05:02 PM
  4. Compare 2 Worksheets Show Differences.
    By NewGuy OnBlock in forum Excel General
    Replies: 1
    Last Post: 12-08-2012, 08:59 AM
  5. Compare Worksheets and Return Differences
    By bkeller83 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2009, 01:52 AM
  6. How to compare Two worksheets and gerenerate differences in 3rd
    By Krishna Sastry in forum Excel General
    Replies: 4
    Last Post: 07-05-2009, 10:52 PM
  7. Compare Two Worksheets:highlight the differences
    By Jim in forum Excel General
    Replies: 1
    Last Post: 10-11-2005, 04:05 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