+ Reply to Thread
Results 1 to 2 of 2

Goal Seek VBA with relative 'Goal' parameter

  1. #1
    Registered User
    Join Date
    05-04-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Goal Seek VBA with relative 'Goal' parameter

    Hi

    Im working on a goalseek macro and I am trying to Change the 'Goal' value based on relative cells such that if the active cell is B4 when the macro is run, the Goal would be the values entered in A3.. and similarly if the macro is run again on cell C5 the goal would be the value entered in B5.

    Ive come up the below VBA code but the way its currently written, the highlighted parameters on the second line agter 'Goal:' inputs a blank as the goal which it shouldnt. This makes me think that the syntax is wrong.

    As you've gathered by now, im a newbie!

    Thanks in advance for your help

    Sub Macro11()
    Sheets("Sheet1").Range("C16").GoalSeek Goal:=ActiveCell.FormulaR1C1 = "=RC[-1]", ChangingCell:=Sheets( _
    "Sheet1").Range("C3")
    Sheets("Sheet1").Select
    Range("C3").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    ActiveCell.Offset(1, 0).Range("A1").Select
    End Sub

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Goal Seek VBA with relative 'Goal' parameter

    2 things here.
    First, your post do not comply with rule #3 which ask you to encolsed your code with CODE tags. See rules for details
    Second, it would help us if you could attach a workbook set up as you want it to work. We won't have to build one from scratch to duplicate what you want to do which can be quite long depending on your specification. Sometimes, it might prevent you to get any answers.
    Regards
    Pierre
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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