VBA Code for bulk Goal Seek

leeandoona

New Member
Joined
Oct 13, 2016
Messages
45
I'm trying (and failing:laugh:) with some VBA code to make a 'Bulk Goal Seek'. My Goal Seek is as follows:

Set Cell Range is G2:G1001
Value I want is 12.00%
Change Cell Range is B2:B1001

So I want to Goal Seek Cell G and convert it to 12% (or closest match) by changing cell B. The other cells contain all the workings that result in a value of 12% but I want to go down 1000 rows repeating this so I hoped I could borrow some code to make it run all at once. Here is the code I was playing with:

Sub BulkGoalSeek()
Dim C As Range
For Each C In Range("B2:B1001")
C.Offset(0, 1).GoalSeek Goal:=C.Offset(0, 2), ChangingCell:=C
Next C
End Sub

Its not workign though. As I borrowed it from another forum, I may be missing something obvious because it does do something, but it runs and changes G to the wrong end result, giving a minus number. Any ideas?:eeek::confused:
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Code:
Sub lee()
  Dim iRow As Long
  
  For iRow = 2 To 1001
    Cells(iRow, "G").GoalSeek Goal:=0.12, ChangingCell:=Cells(iRow, "B")
  Next iRow
End Sub
 
Upvote 0
:cool: Worked brilliantly! Quite speedy too considering how many rows this is over. I see what I did wrong now too :laugh: so that;s a great big thank you for that. Top job!:biggrin:
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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