+ Reply to Thread
Results 1 to 6 of 6

Faster calculation for multiple automatic goal seek

  1. #1
    Registered User
    Join Date
    08-14-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question Faster calculation for multiple automatic goal seek

    Hello all,

    Anyone knows how to get faster calculation for automatic multiple goal seek?

    I use the code below to goal seek three cells:
    H68 to value 252763 by changing C68
    J50 to value 1868.1 by changing C50
    J51 to value 1769.78 by changing C51

    Please Login or Register  to view this content.
    I notice it takes a long time if I use these code to goal seek three times in a sheet. Unfortunately I need to goal seek 19 times for 19 different cells with each different values by changing 19 different cells too.

    So, any idea?

    PS: I notice that if I separate the goal seeks only for two goal seeks in a sheet, it will be faster. I can tackle my problem to goal seeks 19 times by separate them using additional sheet each only consists of two goal seeks program, but I work with large amount of data so I think this solution is inefficient.



    Regards,
    David

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Faster calculation for multiple automatic goal seek

    A sample spreadsheet (or at least a description of the calculations being performed) would help. A couple of thoughts:

    1) Sometimes we use Goal Seek to avoid doing the algebra. In a case like this, one of the first things I would do is check the function in the target cell and see if, using algebra, I can solve the function. Then you'll be able to put 252763 into H68, and put a formula into C68 that will correspond to H68=252763 without even calling Goal Seek.

    2) If the function is one that cannot readily be solved algebraically, I will often write my own algorithm for finding the solution. Goal Seek uses the Newton Raphson method, which is not overly difficult (if you are already familiar with the technique) to code into a UDF. Again, this eliminates the need to call the Goal Seek algorithm.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Faster calculation for multiple automatic goal seek

    Can you turn screen updating off? That might speed things up a bit.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  4. #4
    Registered User
    Join Date
    08-14-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Faster calculation for multiple automatic goal seek

    I just made a spreadsheet that consist exactly of issues I want to solve.

    In the attached file you can see that I want to change values in column "H" to be the value I listed below "Question" by changing value of column "A". I have made the vb program only for 3 rows of data, but I still need other 16 rows of data to be adjusted to my specified value.

    My end goals are:
    1.Data in column H must consist values of 900,800,700,600,400,200, and 100 (that's why you see these numbers in specified value that I want).
    2.Row 1 to 20 must have good distribution values (step) so I can still make a good polynomial trendline from the data.
    3.Cell "H1" must contain value=1966.43 and cell "H20" must contain value=100.

    I don't find other way to achieve my end goals, so now I'm trying to solve this using Goal Seek. But the calculation is too long if I goal seeked all 19 rows of data.

    @MrShorty: I don't think my issue can be solved by using algebraic function in column "A", because there are "if" function in column E. I don't really know how to use Newton Raphson Method in this case. Could you give some examples?

    @mikeTRON: Thanks for the suggestion. I have tried it and unfortunately the calculation still takes time for too long.

    Regards,
    David
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Faster calculation for multiple automatic goal seek

    I don't think my issue can be solved by using algebraic function in column "A", because there are "if" function in column E.
    I expect you already know this, but the if function in column E is there to make sure E never drops below 0 (0<=E<=$K$4). The threshold value for this condition is A=$N$16. The interesting thing -- When E=0 (when A<=$N$16), a lot of the formula in F algebraically drops out, making F (and H) very simple algebraic functions. When A<=$N$16 you should have no trouble solving for x. This could save a significant chunk of computation time, because you will not even need to run goal seek for these entries.

    The main difficulty will be an algorithm for those cases where A>$N$16. If you solve for A assuming E is 0, you should get a good 1st guess at what x should be. From there, figure out a suitable "successive approximation" algorithm that will allow you to solve for x. Perhaps something like this:

    1) Calculate initial guess for A from target value for H assuming E is 0 (same calculation as when A<=$N$16).
    2) From this initial guess for A calculate Fest and Hest.
    3) Using a suitable algorithm, compare Hest with Htarget and use that information to come up with a new guess for A. I might use a linear interpolation type routine (using the TREND() function) to get this next guess for A.
    4) Compare this new A to the previous value for A. If they are the same, exit loop and end calculation. If they are different, return the step 2 with the new A and repeat 2-4.

    If you are comfortable using circular references (with iteration enabled), you could very likely program this calculation without needing to use VBA or Goal Seek at all. If not, there are other options. In any case, I think this should be doable so that it calculates nearly instantaneously. I expect you will need further help building this spreadsheet, so let us know where you get stuck, and we can try to help you get this together.

    If you still want to use your Goal Seek VBA procedures, you might look at them more closely (I don't use VBA to call Goal Seek, so I'm not very good at programming those procedures). I'm not certain why they should take so long to calculate. H is a fairly straightforward, almost linear function of A, so it should not need very many iterations to converge. Perhaps what you need is to use the idea I used of assuming E=0 to give Goal Seek a better 1st guess for A before calling Goal Seek.

  6. #6
    Registered User
    Join Date
    08-14-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Faster calculation for multiple automatic goal seek

    Thank you very much for your help MrShorty. Sorry it took a long time before I reply to this thread.

    It's a great idea using steps you gave.
    Now my mentor that giving me this project has changed the way the excel runs by expanding the number of data (from 20 to 200) so I don't need to get values of A that correspond to numbers in H.

    Perhaps I can use the logic that you explained for other spreadsheet I'm building, I'll let you know if I got any trouble.

    Thanks man.

+ 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. [SOLVED] Automatic Goal Seek
    By Talazem in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-04-2013, 11:28 AM
  2. Automatic Goal Seek VBA won't work now
    By Brodie05 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2013, 08:43 PM
  3. Multiple Goal Seek
    By atamayoz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2012, 01:37 PM
  4. Multiple goal seek ?
    By Joenash in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2007, 12:30 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