+ Reply to Thread
Results 1 to 3 of 3

Goal Seek doesn't run on iterative code

  1. #1
    Registered User
    Join Date
    06-19-2017
    Location
    perth
    MS-Off Ver
    2010
    Posts
    1

    Goal Seek doesn't run on iterative code

    I have a spreadsheet in which one cell, P2 is calculated through a complicated set of iterative functions. I have an input cell P1 that is directly used in the iterations in solving P2. My issue however is that when I goal seek P2 but changing P1, P2 doesn't change and P1 ends up alternating between some arbitrarily large positive and negative numbers.

    I have the iterative calculation option turned on and have also tried using Solver to no avail.

    I dont believe there is an error with the code, as I can manually change P1 in order to get any desired value of P2 so my question is, is there any other reason why goal seek wouldnt work on an iterative function? Because P2 doesnt change at all while the Goal Seek is running, I think there must be something deeper going on.

    Any advice would be much appreciated, Thanks

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,369

    Re: Goal Seek doesn't run on iterative code

    It might help to have some concrete functions to test on. I tried testing using my Newton-Raphson spreadsheets (https://www.excelforum.com/tips-and-...ind-roots.html ) with mixed results. Most of my testing was to use Solver and/or Goal Seek to get a specific root of those polynomials by changing the parameters of the function.

    Goal seek never worked. I observed, as you did, that Goal seek would change the "by changing" cell, but the target cell never changed. Sometimes, when Goal Seek finished, Excel would give me a "circular reference" warning and I would have to force a couple of calculation events (or disable then reenable iterative calculations) to get Excel to correctly calculate the iterative calculation again. I am inclined to believe that Goal Seek is just not sophisticated enough to work with circular references/iterative calculations.

    Solver, on the other hand, gave mixed results. Sometimes, Solver gave a "could not find a solution" message. Sometimes, it would correctly find the solution. I also tested on another equation (more of a continuously increasing exponential function, so it would not have the problems with multiple roots), and Solver worked quite well with this equation (Goal Seek, again, would do nothing). Without knowing more about the sequence of calculations between P1 and P2, I can only guess that Solver's algorithms just don't work well or are unstable with your calculation sequence.

    I can offer no specific suggestions. You might try different starting values -- perhaps if you give Solver a better initial guess, it will be able to find the solution. Or you might look at your calculation sequence and see if there is a more stable sequence of calculations. Or, if you can formalize the steps you use to manually change P1 to get the desired value for P2, perhaps you can program that sequence of steps into the spreadsheet and completely bypass Solver. If you want us to try anything, you will probably need to provide us enough information about your P2=f(P1) calculation so that we have something directly pertinent to your problem to test.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Goal Seek doesn't run on iterative code

    GoalSeek does not seem to like changing value in formula to as a starter. You could perhaps try something like this and see if this works for you.

    Here the problem was that a change in B15 value should fire GoalSeek and changing B16 to set B23 to 0. A manually entered value in B15 fired GoalSeek but if a formula was used macro gave incorrect result.

    Please Login or Register  to view this content.
    The second macro you need should be

    Please Login or Register  to view this content.
    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatic Goal Seek and Calculate Active Sheet Code
    By grifbomber in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2016, 10:42 AM
  2. [SOLVED] Re: VBA code to run Goal Seek
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-10-2014, 06:00 PM
  3. Optimizing goal and seek code.
    By saknem08 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2014, 12:09 PM
  4. VBA Code to run a goal seek
    By michaeldouglas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-10-2014, 02:16 PM
  5. Multiple Goal Seek VBA Code
    By excelwannabeee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-09-2012, 01:30 PM
  6. Help with code for Goal Seek
    By LSB M in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2012, 07:33 PM
  7. Determining VBA Code for Goal Seek
    By BFlick11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2011, 01:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1