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

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
Joined
Feb 10, 2002
Messages
11,654
{=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
Joined
Feb 18, 2002
Messages
13,690
Here's a non array approach

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

Mark W.

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,654
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
Joined
Feb 15, 2002
Messages
5,028
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
for variety

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

Forum statistics

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