Forum Discussion
jamessavery1996
May 07, 2021Copper Contributor
Running an 'if' function if other criteria is met...
Hello Excellers!
If have the following formula in my spreadsheet:
=if(if(D5="", "", if(mod(D5-$C5,1)*24<4, 5, 0))=0, "", if(D5="", "", if(mod(D5-$C5,1)*24<4, 5, 0)))
However, I'd like this to run/only apply if other cells contain specific values. For example, if this formula is in P5, I'd like to to only run/apply if B5 contains the letter 'C' OR the letter 'D'. If it contains 'A', 'B', 'E', 'A_S' or 'A_R', it needs to not run/stay blank.
Anyone can help me? @excel
Perhaps something like this
=IF( NOT(OR(B5="C",B5="D")), IF(D5="", "", IF( IF(MOD(D5-$C5,1)*24<4,5, 0)=0, "", IF(D5="", "", IF(MOD(D5-$C5,1)*24<4, 5, 0) ) ) ), "")
10 Replies
- TwifooSilver Contributor
Perhaps, this formula in P5 fulfills your requirements:
=IF(SUM(COUNTIF(B5,{"*c*","*d*"})), IF(D5="","", IF(MOD(D5-C5,1)*24<4,5,0)), "") - SergeiBaklanDiamond Contributor
And if it contains Z or something else?
- jamessavery1996Copper ContributorIt won't. There's another formula in 'B' that ensures they contain one of the following: A, B, C, D, E, A_R, A_S. So I need the above formula to only run/apply if the relevant 'B' contains either letter C or D.
- SergeiBaklanDiamond Contributor
Perhaps something like this
=IF( NOT(OR(B5="C",B5="D")), IF(D5="", "", IF( IF(MOD(D5-$C5,1)*24<4,5, 0)=0, "", IF(D5="", "", IF(MOD(D5-$C5,1)*24<4, 5, 0) ) ) ), "")