Automate goal seek in two separate worksheets?

tbl921

New Member
Joined
Aug 15, 2018
Messages
1
Hi, I have a model that takes inputs to calculate the estimated cost of a new building. A second output is the estimated monthly payment to finance that cost. This output is based on one of two financing options, which a user selects from a drop down menu. The calculations for that monthly payment are on a distinct tab for each financing option. The calculation lays out, month by month, the loan principle, the monthly payment, and the end of month balance, for the entire term (one option's term is 30 years, the other is 40). I can of course use goal seek for the last end of month balance in each term to determine what the monthly payment would be. But on my forecast sheet, where the user can select inputs (e.g., how many people will live in the building and which financing option to use), the monthly payment is not correct until I manually go to that financing option's tab and run goal seek.

Is there a way to automate goal seek on each of those tabs, so that when the other model parameters change, the goal seek function runs automatically to determine the estimated monthly payment? I have tried some VBA codes pulled from forums, and also tried to record a macro for each tab, but am so far unsuccessful.

Thanks for any help!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Welcome to the Board

Code:
'ThisWorkbook module
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("sheet1")
Set sh2 = Sheets("sheet2")
Select Case Sh.Name
    Case "Sheet1"
        If Not Intersect(Target, sh1.[c4:c13]) Is Nothing Then sh2.[c11].GoalSeek sh2.[e9], sh2.[c4]
    Case "Sheet2"
        If Not Intersect(Target, sh2.[c4:c13]) Is Nothing Then sh1.[c11].GoalSeek sh1.[e9], sh1.[c4]
End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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