# Long excel 2010 sumif multiple conditions exists help

Good evening Gurus,
I have an excel workbook that I need a function to calculate a final % based upon certain conditions.  I am attaching it for review.  Please help if possible.. I am hoping I can achieve with one long function. Please review the PValues to check to see if they need to be included in the final sum.  Thanks for the help!
Example-3z_2.xlsx
Asked:
###### Who is Participating?
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.

EngineerCommented:
I made it to work using a UDF

Enter this formula in N13
=totperc(B13:G13,\$B\$11:\$G\$11,\$B\$10:\$G\$10)+totperc(L13:M13,\$L\$11:\$M\$11,\$L\$10:\$M\$10)+IF(OR(totperc(H13,\$H\$11,\$H\$10),totperc(I13,\$I\$11,\$H\$10)),\$H\$10)+IF(OR(totperc(J13,\$J\$11,J\$10),totperc(K13,\$K\$11,\$J\$10)),\$J\$10)

You would also have to change the cells H10 and J10 to have a single numeric value each.

``````Function totperc(r1 As Range, r2 As Range, r3 As Range)
Dim i As Integer
For i = 1 To r2.Cells.Count
Select Case True
Case r2.Cells(i) = "Y"
If r1.Cells(i) = "Y" Then totperc = totperc + r3.Cells(i)
Case Left(r2.Cells(i), 1) = ">"
If r1.Cells(i) > critval(Right(r2.Cells(i), Len(r2.Cells(i)) - 1)) Then totperc = totperc + r3.Cells(i)
Case Left(r2.Cells(i), 1) = "<"
If r1.Cells(i) < critval(Right(r2.Cells(i), Len(r2.Cells(i)) - 1)) Then totperc = totperc + r3.Cells(i)
Case Left(r2.Cells(i), 2) = "=>"
If r1.Cells(i) >= critval(Right(r2.Cells(i), Len(r2.Cells(i)) - 2)) Then totperc = totperc + r3.Cells(i)
Case Left(r2.Cells(i), 2) = "=<"
If r1.Cells(i) <= critval(Right(r2.Cells(i), Len(r2.Cells(i)) - 2)) Then totperc = totperc + r3.Cells(i)
Case Right(r2.Cells(i), 2) = "Up"
If r1.Cells(i) >= critval(Trim(Left(r2.Cells(i), Len(r2.Cells(i)) - 2))) Then totperc = totperc + r3.Cells(i)
Case Right(r2.Cells(i), 2) = "Dn"
If r1.Cells(i) <= critval(Left(r2.Cells(i), Len(r2.Cells(i)) - 2)) Then totperc = totperc + r3.Cells(i)

End Select
Next i
End Function
Function critval(x)
critval = Val(x)
If Right(Trim(x), 1) = "%" Then critval = critval / 100
End Function
``````
Commented:
Please see attached.

Please check and let me know if anything is missing.

Max Possible 12% does this mean IF the sum is above 12% you wanted to show 12% only else the sum of your range?
Example-3z_2.xlsx
Author Commented:
Yes.. The max possible sum is 12%.
In cells H10 - I10 = EITHER OR /  J10 - K10 = EITHER OR so the max can only be 4% for H10-J10.  All others sum range if they fall within the tolerance.
Commented:
This how I did. Did you see the formula and results.

in the formula I took into account column H and J into account which the max is only 4%.

Plz Let me know if you want any changes.
Commented:
I have edited the formula. The formula is changed based on your need.

Please see attached.
Example-3z_2.xlsx

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Author Commented:
Meets my requirements.  Thanks for the help!
###### 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.