abberyfarm
Well-known Member
- Joined
- Aug 14, 2011
- Messages
- 733
Hi there,
The code below calculates the efficiency of a gear box based on the values in previous cells and set parameters. It has two conditions at the moment, the first being if rc[-1] is 0 then return 0 and the second is ,if the value calculated is greater than 1 then return 1.
My question is how can I modify it to include if the value calculated is less than 0 then return zero.
Thank you
The code below calculates the efficiency of a gear box based on the values in previous cells and set parameters. It has two conditions at the moment, the first being if rc[-1] is 0 then return 0 and the second is ,if the value calculated is greater than 1 then return 1.
My question is how can I modify it to include if the value calculated is less than 0 then return zero.
Thank you
Code:
Range("AC2:AC" & Lastrow3).FormulaR1C1 = "=If(if(rc[-1] = 0, 0, (rc[-2] * rc[-1])/ ((rc[-2] * rc[-1]) + (" & ksl & " * " & Gearratio & " * " & Gearratio & " * " & MaxTorque & " * rc[-1]) + (" & km & " + " & kb & ") * (rc[-2]*rc[-1])))>1,1,if(rc[-1] = 0, 0, (rc[-2] * rc[-1])/ ((rc[-2] * rc[-1]) + (" & ksl & " * " & Gearratio & " * " & Gearratio & " * " & MaxTorque & " * rc[-1]) + (" & km & " + " & kb & ") * (rc[-2]*rc[-1]))))"