Iterative calculation help

beca

New Member
Joined
May 17, 2011
Messages
44
Hi there

I have an equation that requires iterative calcualtion to get the desired value. what I have done is to rearrange the equation to put all the parameters on one side, and set the equation equal to zero, and use "goal seek" function to solve for the desired parameter.

Because I have to do the same thing for about 100 rows, I recorded the process in the macro, and the code looks like as below:

Range("F4").GoalSeek Goal:=0, ChangingCell:=Range("D4")

Then I copied the above function 100 time and changed the cell reference manually in the macro for the rest of the spreadsheet. This works fine, However, when I insert rows in the spreadsheet, I have to manually update the macro as well, which is very frustrating.

Can anyone help me to fully automate the process, so that it is still able to do iterative calculations once I insert a new row.

Thank you
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Code:
ChangingCell:=Range("[B]$[/B]D[B]$[/B]4")
 
Upvote 0
Sorry, That was a typo, it is supposed to be Range("$F$4").GoalSeek Goal:=0, ChangingCell:=Range("$D$4")

But it still doesn't solve the problem when i insert new rows in the spreadsheet.
 
Upvote 0
Try:

Code:
Sub Test()
    Dim LastRow As Long
    Dim i As Long
    LastRow = Range("D" & Rows.Count).End(xlUp).Row
    For i = 4 To LastRow
        Range("F" & LastRow).GoalSeek Goal:=0, ChangingCell:=Range("D" & LastRow)
    Next i
End Sub
 
Upvote 0
Hi Andrew

Thank you for your reply.

I can see what you're trying to do in the code, but the problem is a summary table sits right after the last calculating row, if you set the dim to last row, it won't work, because the summary table has a different table set up from the calculating rows, and the summary table doesn't need iterative calculation either.

I can leave a spare row between the calculating table and the summary table if it can make the spreadsheet work.

Can you please modify the code to suit?

Thank you <!-- / message -->
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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