VBA Code for bulk Goal Seek

leeandoona

New Member
Joined
Oct 13, 2016
Messages
44
I'm trying (and failing:LOL:) 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?:eek::confused:
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,715
Office Version
2010
Platform
Windows
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
 

leeandoona

New Member
Joined
Oct 13, 2016
Messages
44
:cool: Worked brilliantly! Quite speedy too considering how many rows this is over. I see what I did wrong now too :LOL: so that;s a great big thank you for that. Top job!:biggrin:
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,715
Office Version
2010
Platform
Windows
You're welcome.
 

Forum statistics

Threads
1,082,246
Messages
5,363,993
Members
400,772
Latest member
solbebe

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top