Multiple Goal Seek Script

kishorkhanal

Active Member
Joined
Mar 23, 2006
Messages
434
I need a script which does multiple goal seek by changing value in one cell. Here is the script I am using for single goal seek.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Row = 7 And Target.Column = 2 Then
Range("B14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("B12")
End If
End Sub

I want to add in the above script that does the following and so on:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Row = 7 And Target.Column = 2 Then
Range("C14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("C12")
End If
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
This is what I tried but only the first goal seek works.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Row = 7 And Target.Column = 2 Then
Range("B14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("B12")
Range("C14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("C12")
End If
End Sub

I have in total 8 goal seek to incorporate in script.

Please suggest if you have any better ideas. Thanks.
 
Upvote 0
I hope I am clear on my question. If you do not understand, please let me know. It is very important for me to get this done. Please help.
 
Upvote 0
This is what I tried but only the first goal seek works.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Row = 7 And Target.Column = 2 Then
Range("B14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("B12")
Range("C14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("C12")
End If
End Sub

I have in total 8 goal seek to incorporate in script.

Please suggest if you have any better ideas. Thanks.

Not sure.. but if the value in B8 depends on the value in B7 and C7 then try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 7 And (Target.Column = 2 Or Target.Column = 3) Then
Range("B14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("B12")
Range("C14").GoalSeek Goal:=Range("B8").Value, _
ChangingCell:=Range("C12")
End If
End Sub

HTH
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top