how to return zero if formula returns a negative

Dylan driscoll

New Member
Joined
Apr 14, 2013
Messages
9
I'm currently using the following formula to return zero if M3=0.
=IF(AND(M3=0),0,(M3-S3)*(A3-0.58)).
How can I modify this to also return zero if (M3-S3)*(A3-0.58) is a negative.
Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,877
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
You can use the MAX function like this...

=MAX(0,IF(AND(M3=0),0,(M3-S3)*(A3-0.58)))

but I am wondering why you have AND(M3=0) as the first argument to the IF function... why are you using AND when there is only one logical expression as its argument?
 

Dylan driscoll

New Member
Joined
Apr 14, 2013
Messages
9
I've only been using excel for a week and this was the first formula that returned the result I was after.
before you replied I got it to work like this =IF(AND(M3=0),0,IF(AND((M3-S3)*(A3-0.58)<0),0,(M3-S3)*(A3-0.58)))
I guess there is a shorter way to write the same :confused:
I'll go back and try to use the =max
 

Dylan driscoll

New Member
Joined
Apr 14, 2013
Messages
9
The reason I used AND(M3=0),0, is because when M3 is a zero the formula is multiplying a negative by a negative which is obviously a positive. In this case it means an employee being paid extra when he did not work, AND(M3=0),0, stops this from happening
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,880
Messages
5,834,222
Members
430,265
Latest member
CDane

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
Top