excel - How to create a lookup function or VBA code which can return value against only first found result? -
suppose, in sheet1, have order table
orderno. shipmentno. rate 54321 ap2312 54321 ap2312 29781 ap2312 32181 ap2312 54321 ap2312
in sheet2, have rate table
orderno. rate s4321 65
the below table end result trying applying kind of lookup based on sheet2 rate table
orderno. shipmentno. rate 54321 ap2312 65 54321 ap2312 0 29781 ap2312 na 32181 ap2312 na 54321 ap2312 0
which means, formula should return value against first found result viz. 54321 in case.
you may try this
on sheet1 in c2
=iferror(if(countif(a$2:a2,a2)=1,vlookup(a2,sheet2!a:b,2,0),0),"na")
edit: or more correctly this
=if(isnumber(match(a2,sheet2!a:a,0)),if(countif(a$2:a2,a2)=1,vlookup(a2,sheet2!a:b,2,0),0),"na")
Comments
Post a Comment