sum 2 values up to a maximum value

greegan

Well-known Member
Joined
Nov 18, 2009
Messages
644
Office Version
  1. 365
Platform
  1. Windows
Code:
=SUM(IF(B5*D23>2217.6,2217.6,B5*D23)+(IF(B5*D24<786.76,786.76,B5*D24)))
is what I have so far.
I would hope there is a better way to determine the final answer with fewer... functions?
Just to be clear
B5 and D23 are multiplied
if the result is less than 2217.60 then use the result
otherwise max the result at 2217.60

The same with B5 * D23 but the max is 786.76

Thank you as always,

-- g
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
greegan - the three suggestions posted so far all look similar, but they are all subtly different and will, I think, produce different results.
 
Upvote 0
greegan - the three suggestions posted so far all look similar, but they are all subtly different and will, I think, produce different results.
The min formulas seem to give me consistant results.
Thank you for the help

-- g
 
Upvote 0
This is the final formula in the code I'm trying to write based on what you have given me above.

Code:
K2 = (0.15 * (Min(P * C, 2217.6))) + (0.15 * (Min(P * EI, 786.76)))

K2 is the final result
P is 26
C and EI are 31.15 and 13.60 respectively
I seem to be making a mistake using the Min worksheet function within this code as this is giving me a compile error...

"Sub or Function not defined."

C, EI and K2 are all Public currency
P is Public double


I must be missing something very simple?

-- g
 
Upvote 0
This is the final formula in the code I'm trying to write based on what you have given me above.

Code:
K2 = (0.15 * (Min(P * C, 2217.6))) + (0.15 * (Min(P * EI, 786.76)))

K2 is the final result
P is 26
C and EI are 31.15 and 13.60 respectively
I seem to be making a mistake using the Min worksheet function within this code as this is giving me a compile error...

"Sub or Function not defined."

C, EI and K2 are all Public currency
P is Public double


I must be missing something very simple?

-- g
should i be using the if...then statements for this?
 
Upvote 0
You never said this will be in code, but maybe try:

K2 = (0.15 * (application.Min(P * C, 2217.6))) + (0.15 * (application.Min(P * EI, 786.76)))

or:

K2 = (0.15 * (worksheetfunction.Min(P * C, 2217.6))) + (0.15 * (worksheetfunction.Min(P * EI, 786.76)))

Hope that helps.
 
Upvote 0
You never said this will be in code, but maybe try:

K2 = (0.15 * (application.Min(P * C, 2217.6))) + (0.15 * (application.Min(P * EI, 786.76)))

or:

K2 = (0.15 * (worksheetfunction.Min(P * C, 2217.6))) + (0.15 * (worksheetfunction.Min(P * EI, 786.76)))

Hope that helps.
both work great
thank you

-- g
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,459
Members
452,915
Latest member
hannnahheileen

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