+ Reply to Thread
Results 1 to 2 of 2

GoalSeek in VBA

  1. #1

    GoalSeek in VBA

    When if running this code I get the following error, anyone who know
    what the problem is?

    Error:
    "Method 'Range' of object '_Global' failed"


    Sub GoalSeekMacro()

    Source = Worksheets("Olie og gas").Cells(9, 15).Value
    ResultCell = "n9"
    Result = 20
    Range(ResultCell).GoalSeek goal:=Result,
    ChangingCell:=Range(Source)

    End Sub


  2. #2
    Muhammed Rafeek M
    Guest

    RE: GoalSeek in VBA

    Hi

    Use below mentioned macro:

    Sub GoalSeekMacro()

    Dim rngS As Range
    Dim rngD As Range
    Set rngS = Range("O8")
    Set rngD = Range("N9")
    Result = 20
    rngD.GoalSeek Goal:=Result, ChangingCell:=rngS

    End Sub



    "[email protected]" wrote:

    > When if running this code I get the following error, anyone who know
    > what the problem is?
    >
    > Error:
    > "Method 'Range' of object '_Global' failed"
    >
    >
    > Sub GoalSeekMacro()
    >
    > Source = Worksheets("Olie og gas").Cells(9, 15).Value
    > ResultCell = "n9"
    > Result = 20
    > Range(ResultCell).GoalSeek goal:=Result,
    > ChangingCell:=Range(Source)
    >
    > End Sub
    >
    >


+ 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