Hey everyone - first time poster here.
I've managed to piece together a VBA code that works perfectly for my needs. The problem is that the sheet it is on gets adjusted a lot, and I only need the code to run when certain cells are changed (rather than each time any cell is changed).
Here is the code I have now:
Option Explicit
Private Sub Worksheet_Calculate()
CheckGoalSeek
End Sub
Private Sub CheckGoalSeek()
Static isWorking As Boolean
With Sheet1
If Not isWorking Then
isWorking = True
.Range("EqCost1").Value = 0
.Range("GMDeal1").GoalSeek Goal:=.Range("GoalGM"), ChangingCell:=.Range("EqCost1")
.Range("EqCost2").Value = 0
.Range("GMDeal2").GoalSeek Goal:=.Range("GoalGM"), ChangingCell:=.Range("EqCost2")
.Range("EqCost3").Value = 0
.Range("GMDeal3").GoalSeek Goal:=.Range("GoalGM"), ChangingCell:=.Range("EqCost3")
.Range("EqCost4").Value = 0
.Range("GMDeal4").GoalSeek Goal:=.Range("GoalGM"), ChangingCell:=.Range("EqCost4")
.Range("EqCost5").Value = 0
.Range("GMDeal5").GoalSeek Goal:=.Range("GoalGM"), ChangingCell:=.Range("EqCost5")
isWorking = False
End If
End With
End Sub
Put simply, I need this code to run only when a cell in Range "TValueDeal" is changed. Is making this adjustment as simple as adding a couple lines of code, or is there a better way to write the entire thing?
Thanks for your help.
Bookmarks