Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save excelcrafters/74b0ad8f0f8274f8e2bb7eba68f5ec79 to your computer and use it in GitHub Desktop.
Save excelcrafters/74b0ad8f0f8274f8e2bb7eba68f5ec79 to your computer and use it in GitHub Desktop.
Goal Seek analysis for a range with multiple Goals (VBA)
Sub Reset_External_Marks()
'Select the external marks range
Range("E5:E13").Select
'Clear the external marks range
Selection.ClearContents
End Sub
Sub Goal_Seek_Range_MultipleGoal()
'Defining variable k
Dim k As Integer
'We are looping through each row in our table
For k = 5 To 13
'Below is how we replicate the Goal Seek functionality via VBA
Cells(k, "F").GoalSeek Goal:=Cells(k, "H"), ChangingCell:=Cells(k, "E")
'Go to next iteration
Next k
End Sub
@excelcrafters
Copy link
Author

The excel file with demo for "Goal Seek analysis for a range with multiple Goals" is available at https://drive.google.com/open?id=1FSIDrRkYQV7sW_Eo8NDeDMPlNwc88krC

@pxsejpal
Copy link

what if I want my K variable to be a letter; as I want to use the goal seek function column-wise?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment