# If statement

#### patni

##### Board Regular
Hey guys I am stuck with a simple problem.

Basically I am doing sum of Q11:Q31

I need it to sum and show the result but with few IF conditions

cell C3 needs to have some data in it
cell Q2 needs to have some data in it
O33 needs to be equal to P33, V33 and W33

If it does not meet conditions then it would show ERROR
I have this formulae which works perfectly if P33=O33.
However I am not able to do P33=O33=V33=W33

Code:
``=IF(AND(C3<>"",Q2<>"",P33=O33),SUM(Q11:Q31),"ERROR")``

### Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

#### Matty

##### Well-known Member
Re: help with If statement

Hi,

What does this mean:

"O33 needs to be equal to P33, V33 and W33"

Is it that O33 must equal the sum of P33 + V33 + W33? Or O33 = P33 and O33 = V33 and O33 = W33?

Matty

#### patni

##### Board Regular
Re: help with If statement

hey Matty,
the value in O33 needs to be equal to the value in P33, V33,W33

So if O33=1
P33=1
V33=1
W33=1

then i want it to sum
However if the values does not match of all the 4 cell den it would show error

Basically all the 4 cells must have the same value

Last edited:

#### Matty

##### Well-known Member
Re: help with If statement

Hi,

If O33, P33, V33 and W33 are all numeric, try:

Code:
``=IF(AND(C3<>"",Q2<>"",STDEV(O33,P33,V33,W33)=0),SUM(Q11:Q31),"ERROR")``
Else:

Code:
``=IF(AND(C3<>"",Q2<>"",O33=P33,O33=V33,O33=W33),SUM(Q11:Q31),"ERROR")``
Matty

• patni

#### patni

##### Board Regular
Re: help with If statement

Hey Matty,

the above code works perfectly.
Thank you so much for your help.
Thank you