Need Help with Multiple IF in One Cell

intradayteam

New Member
Joined
Feb 15, 2010
Messages
29
I worked out a formula

If A2 is "BUY" then it uses below formula

Code:
=IF(ISBLANK(G2),"",IF(G2>F2,"Rocked",IF(AND(G2<=F2,G2>=E2),"Tgt Done",IF(AND(G2<E2,G2>C2),"Small Profit",IF(G2=C2,"Exit at Cost",IF(AND(G2<C2,G2>D2),"Exit in Loss",IF(G2<=D2,"SL Taken","")))))))

and IF A2 is "SELL" then it uses below formula

Code:
=IF(ISBLANK(G2),"",IF(G2<F2,"Rocked",IF(AND(G2>=F2,G2<=E2),"Tgt  Done",IF(AND(G2>E2,G2<C2),"Small Profit",IF(G2=C2,"Exit at  Cost",IF(AND(G2>C2,G2<D2),"Exit in Loss",IF(G2>=D2,"SL  Taken","")))))))

I want both formulas combined in one cell. I am worried about file size as my sheet has huge data in it. I am not in favour of using VBA as i dont have much knowledge about that.

As far as i searched, Maximum 7 IFs are allowed in each cell formula.

Pls help. If possible try to solve the issue with Formula only (no vba).

Thanks a lot.
 
Great, WOW it worked. Thanks a lot.

There were few errors but i fixed it out. Just added few "=" symbols where needed. Formula is working fine now.

thanks again, Can you pls explain a little bit, why it wasnt working with my formula & how excel allows that much IF function in 1 cell.
Where is SELL thing, I dont find SELL text in formula. I suppose it will count anything else than BUY as SELL. is it ?

Once again thanks for your help.
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
thanks again, Can you pls explain a little bit, why it wasnt working with my formula
I can't help with this - I can't understand your own formula clearly enough. But if you look at it closely yourself, you should be able to spot the differences.

how excel allows that much IF function in 1 cell.
I must admit, this was a bit of an education for me too :)
I always had the "maximum 7 IFs" idea in my head.
But what it actually seems to be is "maximum 7 NESTED Ifs", i.e. within each other.
So, you CAN'T do something like this
Code:
=if(...if(...if(...if(...if(...if(...if(...if(...if(...
but you CAN do something like this
Code:
=if(something,if(...if(...if(...if(...)))),if(...if(...if(...if(...)))))
This formula contains 9 IF statements, but they are NOT all nested within each other.
Depending on the result of the first IF, only 5 IF statements will be evaluated in total.
In effect, this is what the solution provided does.

Where is SELL thing, I dont find SELL text in formula. I suppose it will count anything else than BUY as SELL. is it ?
Yes, that's exactly it.
Of course this assumes that BUY and SELL are the only two possible options. If there are more possibilities, you may need something else.
 
Upvote 0
Got it. Good explanation.

Thanks a lot.

This forum rocks. I visited this forum thousand times and got all required things without even posting it. This was my first post and hurrayyyyyy.. i got the solution.

Thanks to all of you guys. Have a happy life.
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

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