Excel VBA goal seek loop

mizogy

New Member
Joined
Jul 5, 2011
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I've put the following code together to perform using the goal seek function within a named range called "MarginVariance_Cargo". The goal seek needs to go through 10 to 20 iterations due to roundings which are important to zero. To speed the macro up I was trying to find a way to not perform the goal seek should that row of data have no value in it, however hitting a stumbling block. My code is below, any ideas, much appreciated?

_____________________________________________________________________________________
Dim i As Integer

For i = 1 To 20

For Each marginsolve In Range("MarginVariance_Cargo")
If marginsolve.Offset(, 9).Value > 0 Then
marginsolve.GoalSeek Goal:=0, ChangingCell:=marginsolve.Offset(, 2)
End If
Next marginsolve

Next i
______________________________________________________________________________________
Thank you!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
is your function lineair ? otherwise you could use the forecast-function(s).
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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