Custom goal seek methodology

MS_Xsmell

Board Regular
Joined
Jan 27, 2007
Messages
76
Office Version
  1. 365
Platform
  1. Windows
The standard goal seek function runs slowly in a financial model I am building when solving for an acquisition price that meets a user defined investment hurdle target.

Solver seems to provide more efficient options to ‘goal seek’ (newtons method, etc), but some users will not have the addin or ability to install the add in.

Any guidance on code that will use alternative approaches to the standard goal seek application?

It’s a linear function: acquisition price goes up= investment metric goes down… acq price goes down, metric goes up.

Thoughts? Thanks in advance.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
if it's lineair and you have 2 known points, you can calculate a 3rd.
Map2
ABC
3xy
4dataset1510
5dataset2612
6
7known Y, wanted X7,515
8known X, wanted Y36
Blad1
Cell Formulas
RangeFormula
B7B7=FORECAST(C7,B4:B5,C4:C5)
C8C8=FORECAST(B8,C4:C5,B4:B5)
 
Upvote 0
if it's lineair and you have 2 known points, you can calculate a 3rd.
Map2
ABC
3xy
4dataset1510
5dataset2612
6
7known Y, wanted X7,515
8known X, wanted Y36
Blad1
Cell Formulas
RangeFormula
B7B7=FORECAST(C7,B4:B5,C4:C5)
C8C8=FORECAST(B8,C4:C5,B4:B5)
Thanks BSALV.

In my case, the workbook is only showing [dataset1], I'm trying to understand the VBA necessary to perform the following:
  1. save the current X & Y values active in the workbook [dataset1]
  2. change the value of X to a different value and observe the resulting Y value; save the new X&Y values as [dataset2]
  3. use the X & Y values from [dataset1] and [dataset2] to solve for a user defined Y value
Any suggestions? Thanks in advance.
 
Upvote 0
#2 was the manual version, you check with 2 X-values and receive the Y-value, write the 4 values in B4:C5.
Then depending on your situation with a known X or Y what is the corresponding Y or X is line 7 or 8

This is a VBA-version, with a lineair function between X and Y in A15:B15
xxxxxxx.xlsx
AB
14xy
1520046,6666
Blad1
Cell Formulas
RangeFormula
B15B15=100-0.266667*A15

VBA Code:
Sub forecasting()
     Dim myX(1), myY(1)
     
     'part1 : with 2 X-values, what is the Y-value ??
     For i = 0 To 1
          If i = 0 Then Range("A15") = 100 Else Range("A15") = 200
          myX(i) = Range("A15").Value
          myY(i) = Range("B15").Value
     Next
     
     'part2 : what do you want, known Y -> corresponding X ?
     
     MsgBox "intersect with X-axis (Y=0) is at " & WorksheetFunction.Forecast(0, myX, myY)
    MsgBox " with Y=60, the X-value is " & WorksheetFunction.Forecast(60, myX, myY)
    
      'part3 : what do you want, known X -> corresponding Y ?
     MsgBox "intersect with Y-axis (X=0) is at " & WorksheetFunction.Forecast(0, myY, myX)
       MsgBox "with X=150, the Y-value is " & WorksheetFunction.Forecast(150, myY, myX)
End Sub
 
Upvote 0
Solution
#2 was the manual version, you check with 2 X-values and receive the Y-value, write the 4 values in B4:C5.
Then depending on your situation with a known X or Y what is the corresponding Y or X is line 7 or 8

This is a VBA-version, with a lineair function between X and Y in A15:B15
xxxxxxx.xlsx
AB
14xy
1520046,6666
Blad1
Cell Formulas
RangeFormula
B15B15=100-0.266667*A15

VBA Code:
Sub forecasting()
     Dim myX(1), myY(1)
    
     'part1 : with 2 X-values, what is the Y-value ??
     For i = 0 To 1
          If i = 0 Then Range("A15") = 100 Else Range("A15") = 200
          myX(i) = Range("A15").Value
          myY(i) = Range("B15").Value
     Next
    
     'part2 : what do you want, known Y -> corresponding X ?
    
     MsgBox "intersect with X-axis (Y=0) is at " & WorksheetFunction.Forecast(0, myX, myY)
    MsgBox " with Y=60, the X-value is " & WorksheetFunction.Forecast(60, myX, myY)
   
      'part3 : what do you want, known X -> corresponding Y ?
     MsgBox "intersect with Y-axis (X=0) is at " & WorksheetFunction.Forecast(0, myY, myX)
       MsgBox "with X=150, the Y-value is " & WorksheetFunction.Forecast(150, myY, myX)
End Sub
Much appreciated.

It it amazing how much faster this works than goal seek. 5 seconds of excel grinding vs a near instant result. Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,677
Messages
6,173,780
Members
452,534
Latest member
autodiscreet

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