Share via

Microsoft Excel , Goal Seek function

Anonymous
2018-05-16T11:44:47+00:00

Hi, 

I am using the code below to find value on the target cells and  I want to set a condition that the target value obtained in cell (D66 )has to be (>= 0 ), same for ("D66"), ("D68") and ("D70").

1- How can I do that ? and how to add multiple constrains?  

2- and is it OK to use Goal Seek function to solve the value in one cell then use the calculated value into another cell where I set Goal Seek function as       well so I can run multiple Goal seek to do kind of loop to solve 2, 3, 4, 5 or even 6  equations in different cells with different conditions and they             might be related to each other in some how? 

the code is:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim bSuccess As Boolean

    On Error Resume Next

    bSuccess = Range("C66").GoalSeek(0, Range("D66"))

    On Error GoTo 0

    If Not bSuccess Then

        MsgBox "Goal Seek Failed for Cell ""C7""!"

    End If

    On Error Resume Next

    bSuccess = Range("C68").GoalSeek(0, Range("D68"))

    On Error GoTo 0

    If Not bSuccess Then

        MsgBox "Goal Seek Failed for Cell ""DAfStb""!"

    End If

    On Error Resume Next

    bSuccess = Range("C70").GoalSeek(0, Range("D70"))

    On Error GoTo 0

    If Not bSuccess Then

        MsgBox "Goal Seek Failed for Cell ""EC2""!"

    End If

    On Error Resume Next

    bSuccess = Range("C72").GoalSeek(0, Range("D72"))

    On Error GoTo 0

    If Not bSuccess Then

        MsgBox "Goal Seek Failed for Cell ""DAfStb""!"

    End If

On Error Resume Next

    bSuccess = Range("C77").GoalSeek(0, Range("C38"))

    On Error GoTo 0

    If Not bSuccess Then

        MsgBox "Goal Seek Failed for Cell ""DAfStb""!"

    End If

    On Error Resume Next

    bSuccess = Range("C78").GoalSeek(0, Range("C37"))

    On Error GoTo 0

    If Not bSuccess Then

        MsgBox "Goal Seek Failed for Cell ""DAfStb""!"

    End If

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Anonymous
    2018-05-16T23:13:49+00:00

    Well, basically any one can be run automatically and give the solution every time and satisfied the conditions!   

    If you can help me to write that I would appreciated, because I am new user and really need that urgently.

    regards

    Was this answer helpful?

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Anonymous
    2018-05-16T11:46:20+00:00

    Please I need answer ASAP!!!!!!!

    Regards all

    Was this answer helpful?

    0 comments No comments