laner76549
New Member
- Joined
- Jan 8, 2023
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
I am trying to use GoalSeek in excel, however my problem is that the goal for goal seek changes based on goal seeks selected answer. Below I have a code that loops through goal seek, each time setting the goal to an updated value. There are many instances where this code works however, there are a few specific instances that I have found where the code gets stuck in a loop without changing any numbers. (No the two goalseek and goal value do not match.) I am using VBA and the code is listed below, along with a picture of the latest numbers where this operation failed.
Start Code:
Do Until sh.Range(Col_Num(Last_Col + 2) & "63") = sh.Range(Col_Num(Last_Col + 2) & "60")
Set GS = sh.Range(Col_Num(Last_Col + 2) & "63")
Set G = sh.Range(Col_Num(Last_Col + 2) & "60")
Set CC = Sheets("Cross Section").Range("B7")
GS.GoalSeek Goal:=G, ChangingCell:=CC
Loop
End Code
The below is my goalseek value and top is my goal value
Start Code:
Do Until sh.Range(Col_Num(Last_Col + 2) & "63") = sh.Range(Col_Num(Last_Col + 2) & "60")
Set GS = sh.Range(Col_Num(Last_Col + 2) & "63")
Set G = sh.Range(Col_Num(Last_Col + 2) & "60")
Set CC = Sheets("Cross Section").Range("B7")
GS.GoalSeek Goal:=G, ChangingCell:=CC
Loop
End Code