# Compare and then copy cell to separate worksheet

M

#### Matt

This is what I'm trying to do,
1. I have two workbooks, each with data numbered 1-?.
2. I need to have a function that does this:
(workbook 1, cell a2)=10,
if (workbook 2, cell a2)=10 also, then it inserts (w2, cell b2) into (w1,
cell b2).

And on and on down the line... Without having to enter the formula for each
individual row as I have about 2000 rows at this point...

Is there such a formula? Can it be done? It's made my head hurt so far
trying to figure it out. Thanks!

P

#### Pete_UK

I'll assume that both workbooks are open, and guess the filenames. Put
this formula in B2 of workbook1:

=IF(AND(A2=10,A2='[wb2.xls]Sheet1'!A2),'[wb2.xls]Sheet1'!B2,"")

I think this is what you meant, but if the 10 was only an example and
you meant that you want to see if A2 in both workbooks are equal, then
you can simplify it to this:

=IF(A2='[wb2.xls]Sheet1'!A2,'[wb2.xls]Sheet1'!B2,"")

Then select cell B2 again, and double-click the fill handle (the small
black square in the bottom right corner of the cursor) and this will
copy the formula down for you.

Hope this helps.

Pete