# IF function Microsoft Excel

I am trying to sum values from 3 different columns when there is a change in the values

1

I came up with this IF formulas :

``````=IF(AND((B2-A2)=0,(C2-B2)=0),0, SUM(B2:C2))
``````

The formulas work when the value of `(C2-B2) > 0` 2 However, it doesn't take into account the change when `(B2-A2)> 0`3 what argument should I add for my formula ? thank you !

Consider:

``````=IF(AND((B2-A2)=0,(C2-B2)=0),0, SUM(A2:C2))
``````

The `AND()` will be true only if all three values are the same; if false, then sum the three values.

NOTE:

``````SUM(A2:C2)
``````

is the same as:

``````A2 + B2 + C2
``````

if there are numerical values in all three cells.

• Actually i want it to `SUM A2:B2` when `B2-A2 > 0` and `C2:B2` when `C2-B2 > 0` and `A2:C2 `when `B2-A2 > 0 and C2-B2 >0` and return 0 when `(B2-A2)=0,(C2-B2)=0` – sarah Jan 16 '20 at 17:52
• @sarah `=IF(AND((B2-A2)>0,(C2-B2)>0),SUM(A2:C2),IF((B2-A2)>0,SUM(A2:B2),IF((C2-B2)>0,SUM(B2:C2),"")))` – Scott Craner Jan 16 '20 at 18:33
• @ScottCraner Yes !! thank you !! – sarah Jan 16 '20 at 18:53