简体   繁体   中英

Finding a value in a row on another sheet and placing a value in the matching row and column header on current sheet if exists and 0 if it doesnt

So I'm having a little bit of trouble wrapping my head around how to do this. I have a table that looks like this on one sheet

ID    Answer1    Answer2    Answer3   Answer4
1     Apples     Oranges    Bananas   Grapes
2     Bananas    Grapes
3     Apples 
4     Oranges    Bananas

Then I have another table that looks like this on another sheet

ID   Apples    Oranges   Bananas   Grapes
1
2
3
4

What im trying to do is place a 1 in each column for the answer someone picked and 0 if they didn't pick it. So the result would look like the following:

ID   Apples   Oranges   Bananas   Grapes 
1      1        1         1         1
2      0        0         1         1
3      1        0         0         0
4      0        1         1         0

Im not sure what I would use to make this happen but If someone could guide me in the right direction it would be very appreciated

Use a formula like this:

=COUNTIF(INDEX(Sheet1!$B$2:$E$5,MATCH($H2,Sheet1!$A$2:$A$5,0),0),I$1)

This requires that the IDs are unique in the lookup table or it will only bring over the first id that matches.

在此处输入图片说明

You should be able to do this with some simple if logic.

=if('other sheet'!b2="Apples",1,0)

Copy that formula down through the rest of the table, and you should be good to go.

Just try this. You can copy it to every cell of sheet 2.

=IF(COUNTIF('Sheet1'!$A2:$D2;A$1)<>0;1;0)

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