简体   繁体   中英

If cell equals with a value in another cell then cellX

i am trying to use IF in the following arguement:

I have a sheet with a list of products next to it a list with manufacturer. In each product corresponds to a certain manufacturer of the list.

Now how i can tell a cell that if it found in the cell A1 on another sheet the a value from the list of products in the previous sheet to give me as a result the corresponded manufacturer.

I tried the following as a test:

=IF(COUNTIF(B9;data!A:A);data!B:B;"product not found")

were B9 is the cell that i put the product manually, data!A:A is the range of the sheet that i have the list of the products and data!B:B is the list with the manufucturers.

The syntax i guess is ok since its working properly in excel but the thing is that i get always (product not found).

Could please someone help me? Thanks in advance!

I believe you are looking for either Vlookup (to find the corresponding manufacturer), or countif to say whether a manufacturer exists or not.

First: Countif()

 =if(Countif(data!A:A, B9)=0;"Product has mfg", "Product not found")

Second: vlookup()

=Vlookup(B9, Data!A:B, 2, false)

That vlookup will return the manufacturer, if one exists, if it doesn't then you will get an error. It does this by looking up the b9 value in the first column of the range DATA!A:B . When it finds the value, it returns data from the second column (because we put 2 as the third parameter).

If you want to catch the error when the product doesn't have a manufacturer you can wrap the vlookup in an iferror() like:

=IfError(Vlookup(B9, Data!A:B, 2, false), "Product not found")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM