how to return zero if formula returns a negative

Dylan driscoll

New Member
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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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?

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
I'll go back and try to use the =max

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

Replies
2
Views
350
Replies
1
Views
624
Replies
2
Views
532
Replies
2
Views
246
Replies
10
Views
536

1,218,812
Messages
6,144,617
Members
450,560
Latest member
afcmRamos

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.

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

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