# IF AND OR FORMULA

#### joanne10312

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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

#### Mark W.

##### MrExcel MVP
{=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

#### lenze

##### Legend
Here's a non array approach

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

#### Mark W.

##### MrExcel MVP
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)

#### Dave Patton

##### Well-known Member
for variety

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

Replies
8
Views
187
Replies
4
Views
85
Replies
12
Views
245
Replies
7
Views
122
Replies
7
Views
118

1,147,823
Messages
5,743,409
Members
423,792
Latest member
travisds

### 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.

### Which adblocker are you using?

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