Results 1 to 3 of 3

Thread: Need Help on VBA Code with GoalSeek

  1. #1

    Exclamation Need Help on VBA Code with GoalSeek



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I'm having difficulty integrating two nearly-identical codes into one with Visual Basic Editor. Here is the coding that is leading me to trouble.

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Row = 51 And Target.Column = 4 _
    Then
    Range("H47").GoalSeek Goal:=Range("D51").Value, _
    ChangingCell:=Range("D37")
    End If
    If Target.Row = 52 And Target.Column = 4 _
    Then
    Range("H50").GoalSeek Goal:=Range("D5").Value, _
    ChangingCell:=Range("D42")
    End If
    End Sub


    Any guidance is much appreciated!

  2. #2
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    683
    Articles
    0
    Excel Version
    Excel 2010 64bit
    Is your question about GoalSeek or about the Worksheet_Change procedure?

    This code should be located in the sheet's module, not an ordinary inserted module of the VBE.

  3. #3
    Quote Originally Posted by NoS View Post
    Is your question about GoalSeek or about the Worksheet_Change procedure?

    This code should be located in the sheet's module, not an ordinary inserted module of the VBE.
    I found the answer on another thread, but thanks for your quick reply!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •