GoalSeek in Loop

laner76549

New Member
Joined
Jan 8, 2023
Messages
2
Office Version
  1. 365
Platform
  1. 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

1673381635229.png
The below is my goalseek value and top is my goal value
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top