IF AND OR FORMULA

joanne10312

New Member
Joined
Oct 29, 2002
Messages
36
Hello, my problem is this:
two cells that need to be added or subtracted. if cell 1 is a (-) and cell 2 is (+) then cell 1 + cell 2, or if cell 1 is a (-) and cell 2 is a (-), then cell 1 - cell 2, or if cell 1 is a (+) and cell 2 is a (+) then cell 1 - cell 2, if cell 1 is a (+) and cell 2 (-) then cell 1 + cell 2.

thank you!!!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
{=IF(SUM((A1:B1<0)+0)=1,A1+B1,A1-B1)}

where A1 is cell 1 and B1 is cell 2.

Note: This is an array formula which must be entered using the Control+Shift+Enter key combination. The outermost braces, { }, are not entered by you -- they're supplied by Excel in recognition of a properly entered array formula. For more on array formulas see the Excel Help topic for "About array formulas and how to enter them".
This message was edited by Mark W. on 2002-10-30 13:19
 
Upvote 0
On 2002-10-30 13:19, lenze wrote:
Here's a non array approach

=IF(ISEVEN(COUNTIF(A1:B1,"<"&0)),A1-B1,A1+B1)

Or...

=IF(ISEVEN(COUNTIF(A1:B1,"<0")),A1-B1,A1+B1)
 
Upvote 0
for variety

=IF(OR(AND(A2<0,B2>0),AND(A2>0,B2<0)),A2+B2,A2-B2)
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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