+ Reply to Thread
Results 1 to 9 of 9

VBA to compare two worksheets in same book

  1. #1
    Forum Contributor
    Join Date
    01-16-2009
    Location
    Ill.
    MS-Off Ver
    Excel 2010
    Posts
    190

    VBA to compare two worksheets in same book

    Hello all - -

    I have a workbook that contains two worksheets. The columns are the same between the two, column A is the Employee ID in both worksheets. The other column headings are: Name, address1, address2, city, state, zip, EmgerName, EmgerType, Cell, Address1, Address2, City, State, Zip.

    What I'm looking to do is compare WS1 with WS2 and in WS2, what ever is different from WS1, the font color changes to RED. For example let say for employee number 1234, everything is the same expect for EmgerName and Cell, then these fonts are changed to RED in WS2 so I can identify them quickly.

    Thanks for taking time to check this post out, you guys (and gals) are truely very helpful!
    Last edited by Ironman; 01-08-2010 at 01:05 PM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA to compare two worksheets in same book

    A basic example:

    Please Login or Register  to view this content.
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    11-11-2009
    Location
    Columbus, Ohio; USA
    MS-Off Ver
    Excel 2002
    Posts
    70

    Smile Re: VBA to compare two worksheets in same book

    Thank you. Your response is along the lines of what I wanted. I will study it and ask again as I progress. Thanks!

  4. #4
    Forum Contributor
    Join Date
    01-16-2009
    Location
    Ill.
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: VBA to compare two worksheets in same book

    Danexcel - - did you post your response to the wrong thread or perhaps you are greatful for Domski answer? I'm not sure...

    In any case, Domski - Thanks for your quick reply. I like what the code is doing. But one thing, is there a way to modify the code to do a find of the Employee ID number from one sheet to the other, then see if there is a change? Sheet1 may have a different number of rows than Sheet2. Sorry, but I did fail to mention that, the columns will be the same, but the row count would not.

    Thanks tho for you very speedy response...

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA to compare two worksheets in same book

    Sure, I'll have a play and get back to you.

    Just to confirm, am I checking all the numbers that appear on sheet 1 against sheet2? Is it possible there may be numbers on sheet2 that don't appear on sheet1? Can these just be ignored if so?

    Dom

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA to compare two worksheets in same book

    Try this:

    Please Login or Register  to view this content.
    Dom

  7. #7
    Registered User
    Join Date
    11-11-2009
    Location
    Columbus, Ohio; USA
    MS-Off Ver
    Excel 2002
    Posts
    70

    Re: VBA to compare two worksheets in same book

    Oops I don't know how I made the mistake. I posted to the wrong thread yes sorry!

    Well, somehow though I felt it helped me LOL That's a good thing !

  8. #8
    Forum Contributor
    Join Date
    01-16-2009
    Location
    Ill.
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: VBA to compare two worksheets in same book

    Thanks, that is right on perfect! Thank you very much....

  9. #9
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA to compare two worksheets in same book

    Quote Originally Posted by Danexcel View Post
    Oops I don't know how I made the mistake. I posted to the wrong thread yes sorry!

    Well, somehow though I felt it helped me LOL That's a good thing !
    LOL! Cheers for the reputation even if it was by mistake!

    Dom

+ 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