简体   繁体   中英

Excel multiple IF and MATCH or VLOOKUP

I have 4 colums in excel:

* date         weekday      seconds      consider
* 4/03/2016       5           80            Yes
* 5/03/2016       6           80            Yes (if in the table)
* 6/03/2016       7           80            Sunday

Consider cell has formula like below but it doesnt work: =IF(G16=7;"Sunday";IF(G16=6;IF(MATCH(F16;A1:A12;0);IF(AND(J16>$K$2;J16>$K$1);"Yes";"No"));IF(AND(J16>$K$2;J16>$K$1);"Yes";"No")))

What i need is the "consider" field check if the day is sunday, if sunday write 'sunday'. if saturday then check separate table if saturday was working day, if its working day then check if seconds are between 30 and 200 if yes then 'yes' if no then 'no', if saturday is not on a list of working saturdays, then just write 'saturday off', if its any other day check seconds between 30 and 200 if yes then 'yes' if no then 'no'. I will appreciate your help!

Starting with your existing formula, there are four things that you need to do to fix it:-

(1) Put ISNUMBER round the MATCH to avoid it causing an #N/A error if there are no matching Saturday dates.

(2) Put in the "Saturday Off" string.

(3) Change round one of the ">" signs to make the test for seconds between 30 and 200 work.

(4) Change A1:A12 to A$1:A$12 so when the formula is copied down it still works.

This gives you

=IF(G16=7,"Sunday",IF(G16=6,IF(ISNUMBER(MATCH(F16,A$1:A$12,0)),IF(AND(J16<$K$2,J16>$K$1),"Yes","No"),"Saturday Off"),IF(AND(J16<$K$2,J16>$K$1),"Yes","No")))

assuming K1 and K2 contain 30 and 200. If you want to include the case where the seconds are exactly 30 or 200, change < and > to <= and >=.

=IF(G:G<=5,IF(AND(H:H>=30,H:H<=200),"YES","NO"),CHOOSE(G:G-5,IF(ISNUMBER(MATCH(F:F,A:A,0)),
     IF(AND(H:H>=30,H:H<=200),"YES","NO"),"SAT OFF"),"SUNDAY"))

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