View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default How can I combine data from two sheets where field contents ma

The second part of your formula does not quite match the first part.
Try this:

=IF(ISNA(VLOOKUP(A291,Sheet2!A$2:P$27637,2,0)),"no ne",
VLOOKUP(A291,Sheet2!A$2:P$27637,2,0))

if you want data from the second column of Sheet2 - actually, your
range for P only needs to go to 17402, but it doesn't matter if it is
too big.

As you want to get data in consecutive columns from Sheet2, can I
suggest this alternative:

=IF(ISNA(VLOOKUP($A291,Sheet2!$A$2:$P$27637,COLUMN (B2),
0)),"none",VLOOKUP($A291,Sheet2!$A$2:$P$27637,COLU MN(B2),0))

The function COLUMN(B2) will return 2 (which is what you want with the
formula in column Q of Sheet1. When you copy this formula into the
next 3 columns, this will become COLUMN(C2), COLUMN(D2), COLUMN(E2)
etc, which in turn will give 3, 4, and 5, i.e. the columns where you
want to get the data from. Notice that I have put $ symbols in front
of some of the column letters in the cell references - these will not
change when you copy the formula across.

So, all you need to do is put this formula in Q291 and copy it into
R291:T291, format those cells appropriately and then copy the formulae
down the column - a quick way to do this is to double-click the fill
handle with the cursor in Q291 (the small black square in the bottom
right corner of the cursor).

Incidentally, the above is all one formula - be wary of spurious line
breaks on the newsgroups (often introducing a - character at the line
break).

Hope this helps.

Pete

On Jul 6, 10:12 pm, amaries wrote:
Thank you for responding so quick! I am sooo close. Here is my formula,
=IF(ISNA(VLOOKUP(A291,Sheet2!A$2:P$27637,3,0)),"no ne",VLOOKUP(A291,Sheet2!A*$2:A27926,3,))

I am getting 'none' where there is no match, but #REF on the ones where they
actually do match?
My Sheet1 has the PARTID in A which is to match with the PARTID in A on
sheet2.
Sheet1 has data through column P.
Starting in Column Q (where I put this formula) I want
Q(Sheet2/columnB)
R(Sheet2/columnC)
S(Sheet2/columnD)
T(Sheet2/columnE)

Note: Sheet1 has 27926 rows, Sheet2 has only 17402
Where am I going wrong that is is displaying #REF? 'none' is working.