If statement help

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106
Hi all,

The code below calculates the efficiency of a gearbox using the formular1c1 function. The efficiency is calculated in the last part. However sometimes the figure is greater than 1, which means the efficiency is greater than 100% which is not possible. So my question is how can I modify it so that, if the last term is > 1 than return 1, else just the turn the value. I know I could do it in the next column but they are used up and will take ages to change the subsequent code.

Thank you

Code:
Range("r2:r" & LastRow).FormulaR1C1 = "=if(rc[-1] = 0, 0, (rc[-1] * rc[-2])/ ((rc[-1] * rc[-2]) + (" & ksl & " * " & Gearratio & " * " & MaxTorque & " * rc[-1]) + (" & km & " + " & kb & ") * rc[-2]*rc[-1]))"
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This should do it:

Code:
Range("r2:r" & LastRow).FormulaR1C1 = "=IF(if(rc[-1] = 0, 0, (rc[-1] * rc[-2])/ ((rc[-1] * rc[-2]) + (" & ksl & " * " & Gearratio & " * " & MaxTorque & " * rc[-1]) + (" & km & " + " & kb & ") * rc[-2]*rc[-1]))>1,1,if(rc[-1] = 0, 0, (rc[-1] * rc[-2])/ ((rc[-1] * rc[-2]) + (" & ksl & " * " & Gearratio & " * " & MaxTorque & " * rc[-1]) + (" & km & " + " & kb & ") * rc[-2]*rc[-1])))"
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

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