Gain/Loss Calculation

hippo88

New Member
Joined
Apr 7, 2019
Messages
7
Good morning,

I'm trying to write excel formula to take difference between two cells, say J-F and to show that number difference AND the text "gain" or "loss" depends on if the difference is positive (gain) or negative (loss)

if j-f = $2500 cell to show $2500 Gain
or
if j-f = -$110 cell to show -$110 Loss
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
For values in cells J1 and F1, use this formula:
Excel Formula:
=TEXT(J1-F1,"$0") & IF(J1>=F1," Gain", " Loss")
 
Upvote 0
You could also use a custom format to leave the value as a number, so it's available for other formulas. For example:

$#" Gain";"-$"#" Loss";" - ";@

Gives this:

Book1
FJK
1210100-$110 Loss
25003000$2500 Gain
333abc#VALUE!
4Text line
5-
Sheet1
Cell Formulas
RangeFormula
K1:K3,K5K1=J1-F1
 
Upvote 0
@Eric W where do I add the $#" Gain";"-$"#" Loss";" - ";@ portion?
Go to the Cell Format menu (can right-click on cell and select "Format Cells" to see it).
Then go to the Number tab
Choose "Custom" under Category
Copy & Paste what Eric gave you in the Type box.
 
Upvote 0
If you have cents in your values, you might want to use

$#.00" Gain";"-$"#.00" Loss";" - ";@
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,664
Members
449,114
Latest member
aides

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