Change Sign in a Cell When Another Cell Includes but is not Limited to Certain Text

jdpro

Board Regular
Joined
May 1, 2016
Messages
88
Office Version
  1. 365
Platform
  1. MacOS
Hello 🖐️:)

Using the formula: =IF(J43="buy",M43*-1,M43)

I would like to be able to have "buy" and other text in the reference cell and still have it change the result cell to negative when it sees the word "buy". There will be different "buy" items and it would be great to have it in one column rather than having to add another column to show what is being bought. So can a variable be added to the function?

Thanks!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Can you post a sample of your data and the expected results? Your description is not very clear what you want to achieve.
 
Upvote 0
Thanks for asking, dreid1011.

DateActionQtyPriceAmountCost
11/14/23Sell Gadget 1-240308R117.33$17.33$17.33
11/20/23Buy Widget 4612.02$2.02$(2.02)
12/26/23Buy Thing 710050.23$5,023.00$(5,023.00)

In the Action column is the key word "Buy" that I would like to reference, so as to make the value in the Cost column a negative. But I would like to say Buy x and not just "buy." Otherwise I would have to add another Item column. Does this help clarify?
 
Upvote 0
See if this does what you want:
Book1
IJKLMN
42DateActionQtyPriceAmountCost
4311/14/2023Sell Gadget 1-240308R117.33$17.33$17.33
4411/20/2023Buy Widget 4612.02$2.02($2.02)
4512/26/2023Buy Thing 710050.23$5,023.00($5,023.00)
Sheet1
Cell Formulas
RangeFormula
N43:N45N43=IF(ISNUMBER(SEARCH("Buy",J43)),M43*-1,M43)
 
Upvote 1
Solution
Thanks for that really fast fix to my issue! I also am wondering about column M and N. Is it possible to consolidate so I don't have to have both?
 
Upvote 0
Like this?
Book1
IJKLM
48DateActionQtyPriceAmount
4911/14/2023Sell Gadget 1-240308R117.33$17.33
5011/20/2023Buy Widget 4612.02($2.02)
5112/26/2023Buy Thing 710050.23($5,023.00)
Sheet1
Cell Formulas
RangeFormula
M49:M51M49=IF(ISNUMBER(SEARCH("Buy",J49)),(K49*L49)*-1,(K49*L49))
 
Upvote 1
If you are interested, here are a couple of shorter options.

24 03 09.xlsm
IJKLMN
42DateActionQtyPriceAmountAmount
4311/14/2023Sell Gadget 1-240308R117.3317.3317.33
4411/20/2023Buy Widget 4612.02-2.02-2.02
4512/26/2023Buy Thing 710050.23-5023-5023
Amount
Cell Formulas
RangeFormula
M43:M45M43=K43*L43*IF(COUNTIF(J43,"*buy*"),-1,1)
N43:N45N43=K43*L43*(1-2*COUNTIF(J43,"*buy*"))
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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