+ Reply to Thread
Results 1 to 8 of 8

Run goal seek based on changing cell value (that is a formula result)

  1. #1
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Run goal seek based on changing cell value (that is a formula result)

    Hi,
    I have a macro to run goal seek: set B23=0 by changing cell B16. I have that macro run automatically when changes are made to cell B15. This works when I type a number into B15 but when I use a formula based on other cells, the macro gives an incorrect result.

    Please Login or Register  to view this content.
    Any suggestions would be appreciated.

    Thanks,

    Phillycheese

  2. #2
    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,758

    Re: Run goal seek based on changing cell value (that is a formula result)

    Perhaps like this then:

    First you need to save the value in cell B15 when you open the workbook.

    Please Login or Register  to view this content.
    then you check if the value in B15 changes

    Please Login or Register  to view this content.
    and finally you add your SetToZero macro

    Please Login or Register  to view this content.
    Add the macros save the workbook and close it. When you open it the first macro fires and then the second macro will check if B15 value is changed whenever you do something that fires the recalculation of the worksheet. If then the B15 value is different from the original one the third macro will run

    Alf
    Last edited by Alf; 01-31-2018 at 01:34 AM. Reason: explanation of how macro works

  3. #3
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Re: Run goal seek based on changing cell value (that is a formula result)

    Hey Alf,
    I appreciate the code. I got a compile error that the "B15" is not defined (the debug highlights it in the second macro). I don't know how to adjust for this but hopefully once that's set it will work. If you have a moment to assist that would be great.
    Thanks again,
    Phillycheese

  4. #4
    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,758

    Re: Run goal seek based on changing cell value (that is a formula result)

    OK I did a bit of testing and this works for me.

    Please Login or Register  to view this content.
    and you can condense the last code so you only need two of them.

    Please Login or Register  to view this content.
    Hopefully this works for you as well.

    Alf

  5. #5
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Re: Run goal seek based on changing cell value (that is a formula result)

    Hey Alf,
    I appreciate the effort! It works! I deleted the "Option Explicit" I had at the top which may have caused the earlier issue. My data is set up for one employee in column B and I was thinking of including more employees, each with their own data in a separate column. If I'm not imposing (might be too late) would you mind offering a suggestion on how to tweak the code to handle multiple goal seeks that go from column B to column P?
    Thanks,
    Phillycheese

  6. #6
    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,758

    Re: Run goal seek based on changing cell value (that is a formula result)

    offering a suggestion on how to tweak the code to handle multiple goal seeks that go from column B to column P?
    Well now GoalSeek is really not my cup of tea and multiple GoalSeek as far as I know is not possible but I could be wrong of course.

    I think you best option is mark this thread "Solved" and start a new thread where you ask about multiple GoalSeek solutions. A new thread always attracts much more interest than an old one where there has been some action by forum members.

    There is also the Excel add-in Solver perhaps this could be used in order to solve you problem? I would recommend you google for Excel Solver to see if this could be a useful tool.

    Alf

    Ps how to mark a thread "Solved"

    To mark your thread solved do the following:
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

  7. #7
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Re: Run goal seek based on changing cell value (that is a formula result)

    Sounds like a good plan :-) Again, I appreciate the help!

  8. #8
    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,758

    Re: Run goal seek based on changing cell value (that is a formula result)

    You are welcome and thanks for feedback

    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. [SOLVED] Rounded Result with Goal Seek
    By Crownman in forum Excel General
    Replies: 8
    Last Post: 10-12-2018, 12:30 PM
  2. Replies: 3
    Last Post: 05-16-2016, 06:10 PM
  3. Goal seek two cells, by changing two cell
    By salah2112 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2013, 11:29 AM
  4. Changing the value in one cell to make two other cells equal (Goal Seek?)
    By Artie Fufkin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-30-2013, 10:37 AM
  5. Changing formulas based on one cell (period) in worksheet (Goal seek, scenerio?)
    By workingmom434 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-19-2013, 07:34 AM
  6. Replies: 3
    Last Post: 07-27-2012, 01:44 PM
  7. Goal Seek Formula But Not Using Goal Seek
    By cady923 in forum Excel General
    Replies: 1
    Last Post: 08-05-2011, 03:53 PM

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