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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
is your function lineair ? otherwise you could use the forecast-function(s).
 
Upvote 0

Forum statistics

Threads
1,224,835
Messages
6,181,247
Members
453,026
Latest member
cknader

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