+ Reply to Thread
Results 1 to 8 of 8

Re: VBA code to run Goal Seek

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: VBA code to run Goal Seek

    Hi everyone,
    Can I avoid typing 51 values into the Goal argument (in the GoalSeek function)?
    In a recorded macro instead of .Range("B" & i).Value was there a numeric value..
    Any help?

    Please Login or Register  to view this content.
    Last edited by GIS2013; 11-10-2014 at 03:46 PM. Reason: Uninformative headline
    Please * if you like the answer

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: VBA code to run Goal Seek

    Can you provide a short sample of sheet "6.1New", removing personal data, to help to understand the goal seek.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: VBA code to run Goal Seek

    Sure, please see attached.
    Attached Files Attached Files

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

    Re: VBA code to run Goal Seek

    There are no formulas, so it is hard to fully understand what you are doing. My first thought on something like is to step away from Excel and visit the problem algebraically. If I can solve for column F algebraically, then I can simply put a formula in column F and completely bypass the use of Goal Seek. I cannot tell from the sample spreadsheet exactly what the algebra looks like. Does this look correct:

    D=C-B
    E=D/B
    F=D/C (should this be negative?)
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: VBA code to run Goal Seek

    @MrShorty thanks: I'll switch back to Algebra then:
    B=100
    C=120
    D=120-100=20
    E=(120-100)/100=0.2=20%
    F=The percentage value (negative) which makes C=B, in this case 17% [because 120-(120*17%)=100].
    Hope it's clear now, and as far as I know you need to use SeekGoal in order to extract that value (17%). If I'm right, then again I'm looking for a way to feed GoalSeek in a loop (see my original post).

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

    Re: VBA code to run Goal Seek

    120-120*x=100 is easily solved for x (a quick algebra review: http://www.purplemath.com/modules/solvelin3.htm )

    subtract 120 from both sides: -120*x=100-120=-20
    divide by -120: x=-20/-120=1/6 or about 17%

  7. #7
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: VBA code to run Goal Seek

    well you must be right! However, for future generations who might wish to know if all arguments in the GoalSeek function can be indexed, so to be run from a loop.. a general say might be helpful here. To close the thread or leave it open?

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

    Re: VBA code to run Goal Seek

    In a generic sense, it is certainly possible to loop through goal seek. A lot of the particulars will depend on the details of each project. The vast majority of the time, it seems easier to solve the problem algebraically than it is to figure out how to loop through goal seek. That is why the algebraic solution is almost always the first one suggested. But, for those cases where it is not possible to solve it explicitly, Goal seek can be looped, or one can use any number of other root finding algorithms to obtain the desired solution.

+ 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. Goal seek in a Macro
    By Wizards in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2014, 04:04 AM
  2. Goal Seek Macro
    By worswick25 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-02-2013, 07:05 AM
  3. Goal Seek Macro
    By stephenp12 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2011, 06:06 PM
  4. Macro, goal seek
    By bilbonvidia in forum Excel General
    Replies: 1
    Last Post: 07-10-2007, 09:33 PM
  5. [SOLVED] Macro help for goal seek
    By Dean in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2005, 01:30 AM

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