A GoalSeek Macro referencing output from another GoalSeek Macro

PSUinDC

New Member
Joined
Nov 18, 2008
Messages
1
I'm not entirely new to programming, but I am new to VB and Excel Macros.
I am using Excel 2007 on Windows XP.

I have a set of fields that I have a goal seek setup with this macro:

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Row = 1 And Target.Column = 9 Then
Range("AQ26").GoalSeek Goal:=Range("I1").Value, _
ChangingCell:=Range("F26")
End If
End Sub
Whenever I change the cell "I1" (row 1, column 9), it goal seeks AQ26 to equal I1 by changing F26. This macro works like a charm.

My problem starts when I try to make another macro that attempts to Goal Seek whenever F26 (row 26, column 6) changes from the previous Goal Seek.

Code:
Private Sub Worksheet_Change2(ByVal Target2 As Excel.Range)
If Target2.Row = 26 And Target2.Column = 6 Then
Range("AG14").GoalSeek Goal:=Range("F26").Value, _
ChangingCell:=Range("B7")
End If
End Sub
Now, I'm not entirely sure how macro sequences work in excel. I have both of these functions in the same "module" by right clicking the WorkSheet and hitting "view code". The 2nd macro doesn't get an error, but it simply doesn't do anything. I've tripled checked the row/column's to make sure they're right.

Can a macro not work off the event of another macro?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi PSUinDC
Welcome to the board

There is ONLY ONE change event. Your second sub is never executed.

Can't you just execute the 2 goal seeks when I1 changes?

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Address = "$I$1" Then

    Range("AQ26").GoalSeek Goal:=Range("I1").Value, ChangingCell:=Range("F26")

    Range("AG14").GoalSeek Goal:=Range("F26").Value, ChangingCell:=Range("B7")

End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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