简体   繁体   中英

Excel Formula using IF and VLOOKUP Function

CONTEXT

I am trying to update the roster with new players in Sheet1 using data from Sheet2. However, I am trying to only update the males roster info. I have to first verify it is a new player and also that they are male to update the height.

The logic I applied was that IF you found "Yes", and that VLOOKUP returned "Male", then the cell should be populated with a formula that would then use ID # in a VLOOKUP .

EXCEL SAMPLE

*=IF(VLOOKUP("Yes",Sheet2!C2:D6, 2, FALSE) ="Male", "=VLOOKUP(A3, Sheet2!A2:D10, 2, FALSE)", "No")

Sheet1                                         Sheet2
ID #      Height                          ID#   Height      New       Gender    
100         No                            100    66"         No        Female      
101         *                             101    72"         Yes       Male       
102         No                            102    65"         Yes       Female      

PROBLEM

The output of the * is =VLOOKUP(A3, Sheet2!A2:D10, 2, FALSE) in the cell. Is there a way to get Excel to actually evaluate and populate that cell as if that was the original formula?

由于您要查找多个条件,因此请将INDEXMATCH使用:

=IFERROR(INDEX(Sheet2!$B$2:$B$4,MATCH(A3&"YesMale",INDEX(Sheet2!$A$2:$A$4&Sheet2!$C$2:$C$4&Sheet2!$D$2:$D$4,),0)),"No")

You can simply take it out of quotes, but even then I don't think you'll get quite what you want.

Try this:

= IF(
    AND(
        VLOOKUP(A3, Sheet2!$A$2:$D$10, 3, FALSE) = "Yes",
        VLOOKUP(A3, Sheet2!$A$2:$D$10, 4, FALSE) = "Male"),
    VLOOKUP(A3, Sheet2!$A$2:$D$10, 2, FALSE),
    "No")

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