Difference

S

Stevep-4

I am sure there is a very simple answer to this.

I need to calulate the difference between 2 cells (each cell is a SUM of the
information of other cells).

the content of each of these cells could be +ve or -ve. Thus, if A is -45
and B is 200, then the difference is 245.

Is there a simple was of doing this, rather than a long winded IF IF IF
command.
 
B

Bob Phillips

Maybe a slight tweak

=ABS(A1-B1)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
S

Stefi

=B1-A1 gives 245 with your example numbers, Excel knows elementary maths, why
didn't you try it?

Regards,
Stefi

„Stevep-4†ezt írta:
 
H

hot dogs

set up cell 'C' with =if(A>B,A,B) and set up cell 'D' with =if(A<B,A,B)
then in cell 'E' have =C-D, which is the difference between the values.

ensuring that you have the larger value in cell 'C' will stop you from
achieving a negative value for the difference.
 
H

hot dogs

to produce the result using one cell use
=if((A-B)<=0,((A-B)+(2*(0-(A-B)))),(A-B))
 
S

Stevep-4

Thanks Hot dogs, that works. The other suggestions do not work due to the
fact that either cells A or B can be negative.
Thus
If A= -45 and B= 45. Difference is 90
If A= 45 and B= -45. Difference is 90.


Is there a simpler method though, that can be done in one cell? for example
=DIFF(A:B)
 
D

David Biddulph

Stevep-4 said:
I am sure there is a very simple answer to this.

I need to calulate the difference between 2 cells (each cell is a SUM of
the
information of other cells).

the content of each of these cells could be +ve or -ve. Thus, if A is -45
and B is 200, then the difference is 245.

Is there a simple was of doing this, rather than a long winded IF IF IF
command.

=B1-A1
or
=ABS(B1-A1)
depending on what you want.
 
B

Bob Phillips

See my amendment to Roger's response.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
D

David Biddulph

What's wrong with =ABS(A1-B1)? (or =ABS(B1-A1)?)
Doesn't that give 90 for each of your examples?
 
Top