My workbook currently has a cell [e37]) "Neutral Axis" which requires the user to manually input a value until cells [g39] "Ctotal" and [g40] "Ttotal" equal each other. Both Ctotal and Ttotal change based on the value of the Neutral Axis.
I am attempting to solve this iterative problem using a "Do Until" loop by stepping the neutral axis value by 0.1 until the absolute value of "Ctotal - Ttotal" is less than 10.
However when I run my code excel freezes up and eventually crashes. I have run the code with a hard value for the neutral axis and came up with the correct values so I believe the issue is with the Do until loop somewhere.
Any help is appreciated!
Sub neutral_axis() Dim Asc As Integer Dim Ast As Integer Dim V As Integer Dim Ctotal As Integer Dim Ttotal As Integer Dim i As Integer For NA = 1 To [b8] Step 0.1 i = 100 Do Until i < 20 If NA < [b10] Then Asc = NA * [b9] Else Asc = [b13] / 2 - [b11] * ([b8] / 2 - NA) End If Ast = [b13] - Asc V = [e17] * [e25] Ctotal = V + (Asc * [b17]) Ttotal = Ast * [b17] i = Abs(Ttotal - Ctotal) Loop Next NA [E37] = NA End Sub