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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

kishorkhanal

Active Member
Joined
Mar 23, 2006
Messages
434
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.
 

kishorkhanal

Active Member
Joined
Mar 23, 2006
Messages
434
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.
 

facethegod

Well-known Member
Joined
Aug 1, 2006
Messages
767
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,529
Messages
5,854,281
Members
431,635
Latest member
deekay78

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
Top