Created
May 25, 2019 09:30
-
-
Save excelcrafters/0aebaedd6dda67a3d61dd7f8cc47536d to your computer and use it in GitHub Desktop.
Goal Seek analysis for multiple cells/range in Excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Goal_Seek_Range_SingleGoal() | |
'We are looping through each row in our table | |
For j = 5 To 13 | |
'Below is how we replicate the Goal Seek functionality via VBA | |
'Cells(j, "F").GoalSeek - The cell that will hold our Goal value (in this case, Col F) | |
'Goal:=Cells(5, "H") - The value of our goal. In this case its referencing the value of Cell H5 | |
'ChangingCell:=Cells(j, "E") - The input cell that needs to adjust its value inorder to achieve the goal | |
Cells(j, "F").GoalSeek Goal:=Cells(6, "H"), ChangingCell:=Cells(j, "E") | |
'Go to next iteration | |
Next j | |
End Sub | |
Sub Reset_External_Marks() | |
'Select the external marks range | |
Range("E5:E13").Select | |
'Clear the external marks range | |
Selection.ClearContents | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The XLSM file corresponding to this code is available at https://drive.google.com/open?id=1ufBkWspUdWrfFPHJ6cmvEBQ2LRmSqje6