# Google Sheets If else formula I'm trying to write an if else statement in Google Sheets.
I want the value in cell `B2` to dictate what the value you will be in cell `D2`. If the cell `B2` is less than 12 than I want `D2 = 17`, if `B2` is less than 15 but greater than 12 then I want it to equal to 16 and so on and so forth as shown by the code above.

Do I have to use AND?

Yes.
The formula to use would be: The function you are looking could be `IF` or `IFS`.

The syntax is for `IF` is

``````IF(logical_expression,value_if_true,value_if_false)
``````

The syntax for `IFS` is

``````IFS(condition1, value1, [condition2, value2, …])
``````

Reference

• IFS worked. =IFS(B2<12, 17, 12<B2<15, 16, 15<B2<19, 15, 19<B2<22, 14, 22<B2, 13) . Thank you – the_wac Dec 10 '19 at 15:41
• @the_wac Thanks for confirming. Please accept the answer. Ref. What should I do when someone answers my question? – Rubén Dec 10 '19 at 15:43
• actually 12<B2<15, 16, 15<B2<19, 15, 19<B2<22, 14, none of those statements work. Its apparently not the proper format. Do I have to use AND? – the_wac Dec 10 '19 at 16:01
• I'm sorry, it's not clear to me what you mean. Please create a new question including some sample input data, the expected results, the formula that you tried and the result that you got. – Rubén Dec 10 '19 at 16:07