Excel macro to copy, compare and fill cells

Closed
Dee - Nov 26, 2009 at 09:34 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Nov 26, 2009 at 09:46 PM
Hello,
I have two sets of data, the first has regular occurrence based on date, sample shown below:

Plant# Date Job no.
DR15 1-Aug-09 LU009504
DR16 1-Aug-09 LU009505
DR18 1-Aug-09 LU009506
DR19 1-Aug-09 LU009507
DR20 1-Aug-09 LU009508
DR22 1-Aug-09 LU009509
DR23 1-Aug-09 LU009510
DT34 1-Aug-09 LU009511
DT35 1-Aug-09 LU009512
DT36 1-Aug-09 LU009513
DT46 1-Aug-09 LU009514
DT47 1-Aug-09 LU009515
DT48 1-Aug-09 LU009516
DT49 1-Aug-09 LU009517
DT50 1-Aug-09 LU009518

The second set of data occurs in no regular manner, with an event occurring once or many times but has no data in the "Job no." column (which has to be filled up with information from the data above) as below.

Plant# Date Job no.
DR15 1-Aug-09
DR15 1-Aug-09
DR16 1-Aug-09
DR16 1-Aug-09
DR16 1-Aug-09
DR16 1-Aug-09
DR20 1-Aug-09
DR21 1-Aug-09
DR21 1-Aug-09
DR21 1-Aug-09
DT35 1-Aug-09
DT46 1-Aug-09
CP44 1-Aug-09
CR01 1-Aug-09
CR02 1-Aug-09
CR03 1-Aug-09
DR09 1-Aug-09
DR12 1-Aug-09
DR13 1-Aug-09


I need a macro that can compare the two sets of data and where a row in the first data set (Plant# & Date) matches any row in the second data set, the "Job no." in the first data set is pasted in corresponding cells of the second data set.

Can anyone please help?

Regards,
Dee.
Related:

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Nov 26, 2009 at 09:46 PM
in sheet 2 copy paste this formula

=INDEX(Sheet1!$C$1:$C$100,MATCH(1,((Sheet1!$A$1:$A$100=Sheet2!A2)*(Sheet1!$B$1:$B$100=Sheet2!B2)),0),1)


INVOKE THIS FORMULA WITH CONTROL+SHIFT+ENTER.

COPY C2 AND PASTE IT FROM c3 DWON

I have made provision of 100 rows , if more modify the formula
1