+ Reply to Thread
Results 1 to 7 of 7

VBA Code to run a goal seek

  1. #1
    Registered User
    Join Date
    09-09-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    VBA Code to run a goal seek

    Hi There,

    I am in the first tab called "Settings".
    In my 5th tab (called 'Model'), there is a model I want to calculate. But the 'Calculate' button is on the first tab 'Settings'.

    The question is, how to I get my macro to run a goal seek on information from the 5th tab. I tried this. It has not worked.

    Worksheets("Model").Range("B19").GoalSeek Goal:=0.15, ChangingCell:=Worksheets("Model").Range("B16")

    Ther eis a hardcode there for the 15% (0.15) I want to set as a target. Ideally I would like to link this to a cell in the first sheet 'Settings'.

    Help would be much appreciated.

    Thanks

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA Code to run a goal seek

    Hello michaeldouglas,

    Welcome to the Forum.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Thank you
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    09-09-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA Code to run a goal seek

    Thanks for the introduction, much appreciated.

    Please see my test sheet attached. I have given more detail on the first tab as to what I am trying to achieve. Help would be greatly appreciated.

    Thanks
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-09-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA Code to run a goal seek

    Any help people?

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

    Re: VBA Code to run a goal seek

    I am not real skilled at calling Goal Seek from VBA. My thought on approaching this problem.

    Rather than requiring VBA/Excel/myself to look back at "settings" to get the target return rate, I would tend to link this up on "model", then add another helper cell that will calculate the calculated IRR (G12 or G13)-target. Then my goal seek will always be "seeking" a target value of 0.

    See attachment. I have added cells to model to 1) choose equity or capital, and 2) calculate the difference between target IRR and calculated IRR. 3) Goal seek code is unchanged,except for references to target cell and target value. I have also added a link on "result" to the value determined from the Goal seek. I went for a "minimal use of VBA" approach, which means the only VBA statement used is the goalseek statement.
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    09-09-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA Code to run a goal seek

    Quote Originally Posted by MrShorty View Post
    I am not real skilled at calling Goal Seek from VBA. My thought on approaching this problem.

    Rather than requiring VBA/Excel/myself to look back at "settings" to get the target return rate, I would tend to link this up on "model", then add another helper cell that will calculate the calculated IRR (G12 or G13)-target. Then my goal seek will always be "seeking" a target value of 0.

    See attachment. I have added cells to model to 1) choose equity or capital, and 2) calculate the difference between target IRR and calculated IRR. 3) Goal seek code is unchanged,except for references to target cell and target value. I have also added a link on "result" to the value determined from the Goal seek. I went for a "minimal use of VBA" approach, which means the only VBA statement used is the goalseek statement.
    Thank you so much, really appreciate it.

    Nice to know my goalseek part of my code was correct. Might become half decent at this some day

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

    Re: VBA Code to run a goal seek

    Another thing to consider: I'm not a financials guy, so I don't know these functions very well, but it seems that the IRR function, NPV function, and others are interrelated. A lot of times it seems that, with the correct choice of financial function, you can bypass the whole goal seek thing completely. http://office.microsoft.com/en-us/ex...cial_functions

+ 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. Argument not optional error is occurring in goal seek automated code.
    By bk1202 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-21-2013, 08:32 AM
  2. Multiple Goal Seek VBA Code
    By excelwannabeee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-09-2012, 01:30 PM
  3. 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
  4. Replies: 3
    Last Post: 07-27-2012, 01:44 PM
  5. Determining VBA Code for Goal Seek
    By BFlick11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2011, 01:28 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