# Need help with complex formula in excel

If column D = Defend
AND column E or G greater than or equal to 5,000,000
THEN set column N to 1

If column D = Renewal or Upsell or New Business
AND column E or G greater than or equal to 10,000,000
THEN set column N to 1

If column D = Renewal or Run Rate
AND column E or G less than 10,000,000
THEN set column N to 2

If column D = Up Sell or New Business
AND column E or G less than 10,000,000
THEN set column N to 4

If column D = Run Rate
THEN set column N to 2

If column D = New Business
AND column E or G equal to or greater than 10,000,000
THEN set column N to 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Microsoft Excel ExpertCommented:
assuming your data starts from the second row .  put this formula in N2 and copy down
``````=IF(AND(D2="Defend",OR(E2>=5000000,G2>=5000000)),1,IF(AND(D2="Renewal or Upsell or New Business",OR(E2>=10000000,G2>=10000000)),1,IF(AND(D2="Renewal or Run Rate",OR(E2<=10000000,G2<=10000000)),2,IF(AND(D2="Up Sell or New Business",OR(E2<=10000000,G2<=10000000)),4,IF(D2="Run Rate",2,IF(AND(D2="New Business",OR(E2>=10000000,G2>=10000000)),1,""))))))
``````
MSP engineerCommented:
``````=IF(D1="Run Rate";2;IF(AND(D1="Defend";OR(E1>=5000000;G1>=5000000));1;IF(OR(D1="Upsell";D1="New Business");IF(OR(E1>=10000000;G1>=10000000);1;4);IF(D1="Renewal";IF(OR(E1>=10000000;G1>=10000000);1;2);""))))
``````

If the Value in D1 isn't one of the above, or it is Defend with a value less then 5 Million in E and G column the value of N1 is empty
Senior Infrastructure Support Analyst & Systems DeveloperCommented:
Considering the order of processing from top to botton in your question I have formulated the below:

Enter this formula in column N

Microsoft Excel ExpertCommented:
I do not understand it.  when a question is answered, why others are stepping on others toes.

right after the question asked, it has been answered by me.  so, either you spent your time re-inventing the wheel, or simply copying my formula and re pasting it here.
MSP engineerCommented:
- I had the question open and started writing on it, I've never seen your code before I posted my code.
- Raheman and myself also read the question a little bit different than you. we all are correct. Depending on which of the 2 interpretations is correct, that means that or your code is good, of Raheman and mine are good.
- I also looked for impossible combinations and better sorting. If my interpretation is correct, then the last part is already dealth with by part 2, part 5 simpifies part 3 and I also combined part 2 and 4 to make the formula as small as possible.

It also took a little bit longer with my because my Excel is in Dutch, so I hade to write & test my code + translate it to English.
Commented:
Try this:

=IF(D4="New Business", 2, IF(AND(D4="Defend", OR(E4>= 5000000, G4>=5000000)), 1, IF(AND(OR(D4="Renewal", D4="Upsell", D4="New Business"), OR(E4>=10000000, G4>=10000000)), 1, IF(AND(OR(D4="Renewal", D4="Run Date"), OR(E4<=10000000, G4<=10000000)), 2, IF(AND(OR(D4="Up Sell", D4="New Business"), OR(E4<=10000000, G4<=10000000)),4,IF(AND(D4="New Business"), OR(E4>=10000000, G4>=10000000), 1 ))))))
Senior Infrastructure Support Analyst & Systems DeveloperCommented:
Professorjimjam
I never saw your code before I post after I finish in my excel sheet. I opened the question and started working on it and just posted my comment.
I saw your code now and mine is different than you.
Don't worry mate.

Robby, thanks mate
Microsoft Excel ExpertCommented:
it is alright.    no big deal.

I understand
Enterprise ArchitectAuthor Commented:
okay whose on first I need to do some playing to see whose "first" response answered the data call.
Microsoft Excel ExpertCommented:
pinkstonmp

first response was mine

my code was :)

``````=IF(AND(D1="Defend",OR(E1>=5000000,G1>=5000000)),1,IF(AND(OR(D1="Renewal",D1="Upsell",D1="New Business"),OR(E1>=10000000,G1>=10000000)),1,IF(AND(OR(D1="Renewal",D1="Run Rate"),OR(E1<10000000,G1<10000000)),2,IF(AND(OR(D1="Up Sell",D1="New Business"),OR(E2<=10000000,G2<=10000000)),4,IF(D2="Run Rate",2,IF(AND(D2="New Business",OR(E2>=10000000,G2>=10000000)),1,""))))))
``````

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Excel VBA DeveloperCommented:
As a side note to previous experts, may I recommend that you refresh the browser before posting an answer?  That will ensure that you can see if anyone else has supplied an acceptible answer before you.  If you think you have a better solution (more efficient, simpler, easier-to-understand, more-flexible, etc.) then there's no reason not to post.

It happens to all of us; some folks are quick on the draw, but shoot and miss; some wait for the first shot and then get ya right between the eyes.  :-)

-Glenn
Finance AnalystCommented:
To throw another option into the fray, all of the above could possibly be simplified by using a small INDEX table.

Match the Text down a column, match the value across the top, return the value at the intersection.

Thanks
Rob H
Finance AnalystCommented:
See attached, change values in cells A11 & A12 and see result in yellow highlighted cell.

Thanks
Rob H
Q-28528650.xlsx
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.