=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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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