Hello,
I have a need to perform four separate goal seek fuctions in an excel chart. I have been attempting to create a macro that will automate all of these functions when I change a cell. I found this code online to automate one goal seek:
----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bSuccess As Boolean
On Error Resume Next
bSuccess = Range("G18").GoalSeek(0, Range("C18"))
On Error GoTo 0
If Not bSuccess Then
MsgBox "Goal Seek Failed for Cell ""C18""!"
End If
End Sub
Sub GoalSeek()
End Sub
---------------------------------------------------------------------
This code works perfectly. However, I wanted to automate the goal seek function for three other cell-pairs. I created three other identical macros and simply changed the "Range" and "GoalSeek" values to match the other cells. (I also had to alter the "Worksheet_Change" name for each macro.)
I ran the macros and there were no error messages. However, when I change a cell value, only the first goal seek function is automated.
Any suggestions on how to automate all of the goal seek functions at once would be greatly appreciated
I have a need to perform four separate goal seek fuctions in an excel chart. I have been attempting to create a macro that will automate all of these functions when I change a cell. I found this code online to automate one goal seek:
----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bSuccess As Boolean
On Error Resume Next
bSuccess = Range("G18").GoalSeek(0, Range("C18"))
On Error GoTo 0
If Not bSuccess Then
MsgBox "Goal Seek Failed for Cell ""C18""!"
End If
End Sub
Sub GoalSeek()
End Sub
---------------------------------------------------------------------
This code works perfectly. However, I wanted to automate the goal seek function for three other cell-pairs. I created three other identical macros and simply changed the "Range" and "GoalSeek" values to match the other cells. (I also had to alter the "Worksheet_Change" name for each macro.)
I ran the macros and there were no error messages. However, when I change a cell value, only the first goal seek function is automated.
Any suggestions on how to automate all of the goal seek functions at once would be greatly appreciated