PDA

View Full Version : Code to match two sheets and display differences



daymood
05-17-2008, 07:16 AM
Hi,

Right now i'm busy with my finishing school-project. Hopefully you guys can help me to solve my problem! I want to create a macro to do the following:
I've two sheets. Sheet1 is housing data for more than 5000 rows and sheet2 for about 7000 rows. I want to make a macro that matches the two sheets and sheet3 needs to display the differences between both sheets. I made an example:


Sheet1
Column A Column B Column C Column D Column E Column F
Date ID-number Employee# Name Account# Amount
1-1-2007 AD1010345 V-001-BVC Ben 75210201 $7.000,00
28-1-2007 FR5289889 A-005-JRD John 25941230 $6.500,00
2-2-2007 HL1589789 G-004-THO Ted 56214790 $4.500,00
5-2-2007 BN7364103 C-075-POL Peter 21586466 $7.000,00
11-3-2007 TG5897466 E-014-CRY Chris 46782647 $3.500,00
etc.


Sheet2
Column A Column B Column C Column D Column E Column F
Date ID-number Employee# Name Account# Amount
1-1-2007 AD1010345 V-001-BVC Ben 75210201 $7.000,00
28-1-2007 FR5289889 A-005-JRD John 25941230 $6.000,00
2-2-2007 HL1589789 G-004-THO Ted 56214790 $4.500,00
1-3-2007 WF3189157 D-311-MDG Matt 85961432 $5.500,00
11-3-2007 TG5897466 E-014-CRY Chris 46782647 $3.500,00
etc.

The macro has to match both sheets and needs to use ID-number, Employee#, Name, Account# and Amount as criteria for matching the data! This will give the following result, as its create a third sheet in the active worokbook:

Sheet3
Column A Column B Column C Column D Column E Column F
Date ID-number Employee# Name Account# Amount
5-2-2007 BN7364103 C-075-POL Peter 21586466 $7.000,00
28-1-2007 FR5289889 A-005-JRD John 25941230 $6.000,00
1-3-2007 WF3189157 D-311-MDG Matt 85961432 $5.500,00

I hope you can help me out guys.
Lots of thanks!

Bob Phillips
05-17-2008, 08:49 AM
Cross-posted at MrExcel http://www.mrexcel.com/forum/showthread.php?t=320137

Simon Lloyd
05-18-2008, 12:58 AM
Thanks Bob!, daymood please read the link in my signature titled "Please Read This Before Crossposting" the word "this" being the link!

Simon Lloyd
05-18-2008, 01:02 AM
Please also see this (http://www.vbaexpress.com/forum/faq.php?faq=psting_faq_item#faq_hom_faq_item) link with regards to your statement at the beginning of your post!