=A2-A1 if answer is negative =A1-A2

dixon1983

Board Regular
Joined
Apr 23, 2005
Messages
175
Hi,
Can anyone help with this?
I would like to put a formulae in a cell that calculates A2-A1 but if the answer returned is negative to calculate A1-A2.

Can this be done??

Thanks in advance
 
Glen, you're right. I was forgetting that he wanted to reverse the subratction to always get a positive result.

I was going by his example of:
=ABS(A1-A2)+1 doesnt return the same value as (A2-A1)+1

Where A1 is say, 10, and A2 is 5.

ABS(10-5)+1 = 6
(5-10)+1 = -4

I forgot he wanted to switch the order of subraction in the 2nd example when the result is negative.

Sorry... need to get my brain in gear.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Apologies.....

The formulae I actually had was =ABS(A1-A2+1). The ABS was in an IF function and all the brackets confused me.... I didnt realise the +1 was still inside the ABS brackets....

Thanks again for all your help.
Sorry for causing arguments :devilish:
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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