How to pick and assign formula on behalf of cell color

pankajgrover

Board Regular
Joined
Oct 27, 2022
Messages
99
Office Version
  1. 365
Platform
  1. Windows
Hi, i am doing copy paste formula according to buy sell option. But i want if cell have green color this Formula =(((F22-L22)*B22)*C22)-AI22+O22-N22 apply or if have red color this Formula =(((F21-L21)*B21)*C21)-H21+AI21 apply in same Net result column. Still now i doing manually and How i do that automatic? I want in below example AI column auto pick formula from cell AG16, AG17 color based .Should i do any conditional formatting ? Thanks

Shares Trading (1).xlsx
ACADAEAFAGAI
15Net result
16Oil6621.0023/12/20220.56500.00-6050
17Gas430.0023/12/20221410.0025500
sheet
Cell Formulas
RangeFormula
AI16AI16=(((F16-L16)*B16)*C16)-H16+AH16
AI17AI17=(((F17-L17)*B17)*C17)-AH17+O17-N17
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How are the cells getting coloured green or red?
- Conditional Formatting?
- vba?
- Manual?
- Something else?
 
Upvote 0
How are the cells getting coloured green or red?
- Conditional Formatting?
- vba?
- Manual?
- Something else?
I will do it manual cell color that's no issue. but i want result formula pick from color. Another idea was in my mind that i insert 1 more column and give value S or B sale or Buy , and that defines result formula. But i happy with manual color because its easy for me understand that values green and red means buy and sale data without the need of 1 extra column. Thanks
 
Upvote 0
To me it would make more sense to add that extra column with B or S. That will make the formula choice easy and you can also set up Conditional Formatting to automatically make the row green or red depending on that B or S value in the extra column.
 
Upvote 0
To me it would make more sense to add that extra column with B or S. That will make the formula choice easy and you can also set up Conditional Formatting to automatically make the row green or red depending on that B or S value in the extra column.
If i go with extra column how to do that result column pick formula on based of B or S ? if can i also go with color based option formula pick up pls also share how to do that ? I just want formula in auto mode in only AI column in above example . Thanks
 
Upvote 0
Try something like this. Ignore the actual results in column AI as I did not have your values for column B, C, F etc I just made up some numbers to check that my formulas gave the same results as yours.

22 12 25.xlsm
ACADAEAFAGAIAJ
15Net result
16Oil6621449180.56500-27S
17Gas43044918141041B
Buy Sell
Cell Formulas
RangeFormula
AI16:AI17AI16=(F16-L16)*B16*C16+IF(AJ16="S",-H16+AH16,-AH16+O16-N16)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AE16:AJ17Expression=$AJ16="B"textNO
AE16:AJ17Expression=$AJ16="S"textNO
 
Upvote 0
Try something like this. Ignore the actual results in column AI as I did not have your values for column B, C, F etc I just made up some numbers to check that my formulas gave the same results as yours.

22 12 25.xlsm
ACADAEAFAGAIAJ
15Net result
16Oil6621449180.56500-27S
17Gas43044918141041B
Buy Sell
Cell Formulas
RangeFormula
AI16:AI17AI16=(F16-L16)*B16*C16+IF(AJ16="S",-H16+AH16,-AH16+O16-N16)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AE16:AJ17Expression=$AJ16="B"textNO
AE16:AJ17Expression=$AJ16="S"textNO
This is working . Thanks. If i opt for cell color instead of creating new column B or S. I just asking for knowledge purpose , Like below what will be code for replace Bold words
=(F16-L16)*B16*C16+IF(AG16="Cell color is red",-H16+AH16,-AH16+O16-N16)
 
Upvote 0
You would need to use vba not standard worksheet functions.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,431
Members
449,158
Latest member
burk0007

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