Macro to Compare two sheet with both sheets

February 2017




Issue


I have a 2 excel sheet which has all the column having same. This has D$C Comment, OMS comments, Planned Resolution date & Sub account in both the sheets

1st excel sheet has above mentioned subtitles are filled with data but the second sheet doesn't have data for D&C comments, OMS comments & planned resolution but has data for sub account

Sub account is the columns which is common in both the sheets filled with Data. This is basically a number given to account eg: Jp0224, KR0345 etc


1st Sheet has

Reason for Outstanding Action Taken Planned resolution Sub a/c
1 Timing issue Removed 30 Aug 10 Jp2035
2 Permission not dropped Sent mail 9 JUl 10 SG0235

2nd Sheet has

Reason for Outstanding Action Taken Planned resolution Sub a/c
1 Jp2035
2 SG0235


Now I need a macro for 2 excel sheet where in with reference to Sub a/c column it need pull data form 1st sheet to 2nd sheet in columns Reason Outstaying, Action Taken, Planned resolution

For above case the in 2nd sheet it should look like the first sheet.

Solution


You do not need a macro...

in sheet 2 in A2 copy paste this formula
=INDEX(Sheet1!A$2:A$100,MATCH(Sheet2!$D2,Sheet1!$D$2:$D$100,¬0),0)


and hit enter key.

I am assuming that there are less than 100 rows. see 100 in the above formula and also see the dollar signs in the formula

copy A2 in sheet 2 down as long as data is there and to the right till the column C

Note


Thanks to venkat1926 for this tip on the forum.

Related


Published by aakai1056. Latest update on March 2, 2010 at 02:40 PM by aakai1056.
This document, titled "Macro to Compare two sheet with both sheets," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).