Just to make sure I understand correctly, when B5 is within 2% of C5 (either greater than, equal to, or less than), should the formula return "2"? If so, you can use the following formula:
=IF(ABS(B5-C5)<=C5*0.02,2,IF(B5>C5,1,3))
This formula returns "2" when B5 is exactly 2% less than or exactly 2% greater than C5. If you want it to return "3" and "1" in these cases respectively, you can use the following instead:
=IF(ABS(B5-C5)<C5*0.02,2,IF(B5>C5,1,3))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…