Find the difference between two cells

2019-08-30 04:20发布

问题:

Below is the example of my Excel sheet. In that I want to find the Gain and Loss using the E and D cells. If E>D it should calculate E-D and the value should be entered in F cell and if E

回答1:

Enter this formula into cell F2:

=IF(E2 > D2, E2 - D2, "-")

Then enter this formula into cell G2:

=IF(E2 <= D2, E2 - D2, "-")

For a row where something is not a gain or a loss, a - dash will appear in that column.



回答2:

Use the IF() Function.

In the GAIN column, try:

=IF(E2>D2, E2-D2, 0)

In the Loss column, try:

=IF(E2<D2, D2-E2, 0)