skorpio911
New Member
- Joined
- Jul 6, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
I am working on an excel model. I have successfully planted a VBA code for automatic calculation, but it only works if I change the targeted value manually (which in actuality is based on a calculation from another sheet).
Long story short, VBA-coded Goal Seek is not reacting to an automatic change in targeted value by manipulating some other variables in another sheet as it is linked.
I am using the following code. Please help me out. Thank you!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim inputCells As Range
'List all input cells
Set inputCells = Range("MaxPowerOutput, NoOfTurbines, RequiredPower")
'Run the macro if an input cell changes
If Not Application.Intersect(Range(Target.Address), inputCells) Is Nothing Then
'Run the Goal Seek using the values in the NoOfTurbines
Range("MaxPowerOutput").GoalSeek Goal:=Range("RequiredPower"), ChangingCell:=Range("NoOfTurbines")
End If
End Sub
Long story short, VBA-coded Goal Seek is not reacting to an automatic change in targeted value by manipulating some other variables in another sheet as it is linked.
I am using the following code. Please help me out. Thank you!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim inputCells As Range
'List all input cells
Set inputCells = Range("MaxPowerOutput, NoOfTurbines, RequiredPower")
'Run the macro if an input cell changes
If Not Application.Intersect(Range(Target.Address), inputCells) Is Nothing Then
'Run the Goal Seek using the values in the NoOfTurbines
Range("MaxPowerOutput").GoalSeek Goal:=Range("RequiredPower"), ChangingCell:=Range("NoOfTurbines")
End If
End Sub