IF Command

kashifjillani

New Member
Joined
Jul 26, 2011
Messages
47
Hello dear community,

I want to use (may be) IF command to perform following task

There are two cells I want to add, but if one of values in those cells is zero then I dont want to add at all. Just zero may appear as result.

e.g.

cell A1 value is 2
Cell B3 value is 4

then sum A1+B3 = 6

BUT IF:

cell A1 value is 0
Cell B3 value is 4

then sum A1+B3 = 0
:confused:
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the board.

Yes an 'if' command will do what you need here but you would also need an 'or'. type this into the formula bar:

=if(or(A1=0,B3=0),0,A1+B3)

This will pick up a zero (or blank) in either cell and make the result 0. Everything else it will add the two cells.
 
Upvote 0
Welcome to the board.

Yes an 'if' command will do what you need here but you would also need an 'or'. type this into the formula bar:

=if(or(A1=0,B3=0),0,A1+B3)

This will pick up a zero (or blank) in either cell and make the result 0. Everything else it will add the two cells.

Many thanks Ben Burgess
 
Last edited:
Upvote 0
Other slight variations would be

=IF(A1*B3,A1+B3,0)
=(A1+B3)*(A1*B3<>0)
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top