Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to change the value of a cell in Google Sheets based on the value of an adjacent cell. This adjacent cell gets its value from the colour of the cell adjacent to it using the formula from this Quora answer. So the value of the cell should change based on the hex code which is obtained from the colour of the first cell. There are 4 possible hex values at the moment so I was trying to put 4 different if statements in the same cell so its value is changed based on this.

My first attempt led to a formula parse error:

=if((J2="#00ff00","Read"), if(j2="#ff0000", "Unread"), if(j2="#ff9900","In Progress"), if(j2="#000000", "Not Applicable"))

It is clear you cannot simply separate if statements with commas. Based on this stack overflow question I tried this code, with nested if statements:

=if((J2="#00ff00","Read", if(j2="#ff0000", "Unread", if(j2="#ff9900","In Progress",if(j2="#000000", "Not Applicable")))))

This also leads to a formula parse error.

Is there any way I can simply include multiple if statements in the same cell which will work for my code?

Note: Thanks for any help, I am happy to test any code and answer further questions. Please edit if necessary.

share|improve this question
Can you combine them into an =OR or something similar? – AccioBooks Jan 23 at 14:53
up vote 9 down vote accepted

Use lookup instead of if:

       {"Not applicable", "Read","Unread","In Progress"}

Note the second parameter must be a sorted list.

share|improve this answer
Thank you very much, this works perfectly! – Jack Graveney Jan 23 at 17:59

Short answer

The problem in the examples provided are the parenthesis. Apply them properly.


IF() function should have two parameters and optionally a third one.

IF(logical_expression, value_if_true, value_if_false)

The specific problem with

  • the first example provided is that the outer IF() has too many parameters.
  • the second example is that the logical_expression of the outer IF() do not return TRUE or FALSE

In Google Sheets functions the parameters are separated by commas. When parenthesis are used to enclose several operations and functions inside a function they are considered as a parameter of the function that contains them.

A common practice is to put the inner IF() as the value_if_false, but it could be done in many ways. Adding IF() inside another other as value_if_true and value_if_false is called IF() logical test nesting or just IF() nesting.

Below is an example of a formula that have having three IF(), two of them used to determine the value_if_false of the parent IF(). A multi-line and vertical align of parenthesis style is applied for readability

 =IF(logical_expression, value_if_true, 
     IF(logical_expression, value_if_true, 
        IF(logical_expression, value_if_true, value_if_false

The above style could be used in Google Sheets formula writing. I found it useful for formula debugging.


share|improve this answer

You can nest IF statements for example

If(if(if(when all 3 equal true)))

Would work


you could use a nested IFAND for example


Would also work.

share|improve this answer
The IF() function requires at least two parameters. See webapps.stackexchange.com/a/89068/88163 – Rubén Jan 25 at 15:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.