+ Reply to Thread
Results 1 to 5 of 5

Determining VBA Code for Goal Seek

Hybrid View

BFlick11 Determining VBA Code for Goal... 10-31-2010, 01:32 PM
TMS Re: Determining VBA Code for... 10-31-2010, 03:41 PM
BFlick11 Re: Determining VBA Code for... 11-04-2010, 02:56 PM
TMS Re: Determining VBA Code for... 11-04-2010, 03:05 PM
Kinchen Re: Determining VBA Code for... 09-12-2011, 01:28 PM
  1. #1
    Registered User
    Join Date
    10-04-2010
    Location
    Blacksburg, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Determining VBA Code for Goal Seek

    Can someone please tell me what the VBA would be for the following question:

    You need to plot the series of x,y points that solve the equation
    exp(x+y)=(x^2)/y - y^2
    For the range of x values shown below. Set up the Excel worksheet to solve this problem using Goal Seek for each row. Write a VBA macro program that uses a FOR/NEXT loop that can be associated with the command button to solve the entire problem. You can use the extra columns if desired.

    NOTE: THe problem also has screen shot of excel looking like this:


    [SOLVE FOR Y] <------Button
    A B C D
    4 x y
    5 1
    6 2
    7 3
    8 4
    9 5
    10 6


    I appreciate the help!
    Brandon

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,099

    Re: Determining VBA Code for Goal Seek

    Are you just going to hand in whatever solution you're given and take the credit?

    I hope there's an exam ;-)
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-04-2010
    Location
    Blacksburg, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Determining VBA Code for Goal Seek

    Quote Originally Posted by TMShucks View Post
    Are you just going to hand in whatever solution you're given and take the credit?

    I hope there's an exam ;-)
    correct...so you want to help me out?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,099

    Re: Determining VBA Code for Goal Seek

    I'll give that a miss, thank you.

    Looks an interesting question, in a theoretical way ... but I missed the lectures ;-)

  5. #5
    Registered User
    Join Date
    08-30-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Determining VBA Code for Goal Seek

    Set a cell say A1 =exp(A2+B2)
    Set a ell say B1 = (A2^2)/B2 -B2^2
    Set a cell say D1 = A1 - B1
    You want to set this cell =0 in your goal seek function.
    Say x = 1 is in cell A5 and the corresponding y is in Cell B5 and you want to calculate to x = 5

    sub ()
    Dim a as Integer
    For a = 0 To 4
        Range("A5").Offset(a, 0).Select
        Selection.Copy
        Range("A2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
         Range("B2").Value = 1
        Range("D1").Select
        Range("D1").GoalSeek Goal:=0, ChangingCell:=Range("B2")
        Range("B2").Select
        Range("B2").Copy Range("B5").Offset(a, 0)
    Next a
    End Sub
    So I use Cell A2 and B2 to do separate each scenario. There is a way to do it without this workaround but this is the same way as I have in my code. As for the first part of your request. Just add a command button to where ever you like on your page and then right click it and assign a macro (ie. what ever you name this one) and voila

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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