recalculation in vba

okang

New Member
Joined
Nov 25, 2005
Messages
1
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
.
.
.
.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
If you store your axial load value on a sheet somewhere.

Application.Calculate

should work.
 
Upvote 0
If you bury your Axial Load calculation inside the Do While loop and run an exit command based on meeting certain criteria then the loop is performing the iteration for you.
 
Upvote 0

Forum statistics

Threads
1,207,195
Messages
6,077,010
Members
446,250
Latest member
Dontcomehereoften

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