Hi. I am trying to write a code by using VB in Excel that can determine the moment-curvature relationship of a reinforced concrete cross section, but I have limited information about VBA. To do so, at first a “c” value should be assumed and then by checking if “the axial load calculated” for that “c” is equal to “the applied axial load”. Then a new “c” value, depending on three conditions I prepared, should be assumed and same procedure should be performed until “the axial load calculated” is equal to the “applied axial load”. My problem is that I couldn’t be able to update the axialload calculation using the new c value, so the do while condition does not change, so the loop does not stop until c is equal to the max value that can be defined using dim types. At the beginning I tried GoalSeek function but due to some error ,with code 1004 I think, it did not work. Then I prepared some iteration although it is not a good one. Does anybody know how to handle this kind of problem either using goal seek or iteration?
AppliedAxialLoad=defined by user
h=defined by user
c=h/2(initially should be different than zero to prevent division by zero error, so I assumed)
.
.
AxialLoad=calculated by some loops depending on “c”
.
.
Do While Abs(AxialLoad) < 0.99 * AppliedAxialLoad Or Abs(AxialLoad) > 1.01 * AppliedAxialLoad
If AxialLoad > 0 And AxialLoad > AppliedAxialLoad Then
c = c * 0.99(c should be decreased)
*****AxialLoad should be recalculated!
ElseIf AxialLoad > 0 And AxialLoad < AppliedAxialLoad Then
c = c * 1.01(c should be increased)
***** AxialLoad should be recalculated!
ElseIf AxialLoad < 0 Then
c = c * 1.01(c should be increased)
***** AxialLoad should be recalculated!
End If
Loop
.
.
.
.
AppliedAxialLoad=defined by user
h=defined by user
c=h/2(initially should be different than zero to prevent division by zero error, so I assumed)
.
.
AxialLoad=calculated by some loops depending on “c”
.
.
Do While Abs(AxialLoad) < 0.99 * AppliedAxialLoad Or Abs(AxialLoad) > 1.01 * AppliedAxialLoad
If AxialLoad > 0 And AxialLoad > AppliedAxialLoad Then
c = c * 0.99(c should be decreased)
*****AxialLoad should be recalculated!
ElseIf AxialLoad > 0 And AxialLoad < AppliedAxialLoad Then
c = c * 1.01(c should be increased)
***** AxialLoad should be recalculated!
ElseIf AxialLoad < 0 Then
c = c * 1.01(c should be increased)
***** AxialLoad should be recalculated!
End If
Loop
.
.
.
.