VBA goalseek range

MetalBee

New Member
Joined
Jul 23, 2013
Messages
16
I am new to VBA and using Excel 2010.

I need to apply a goalseek to each row in range T2:T19698, set to value 0.4, by changing each value in range S2:S19698

Can anyone help please?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You can try this:

Code:
Sub Goal_Seek_Column()
Application.ScreenUpdating = False
Dim i As Long, lastrow As Long

With ActiveSheet
lastrow = Cells(Rows.Count, "T").End(xlUp).Row

For i = 2 To lastrow
    Range("T" & i).GoalSeek Goal:=0.4, ChangingCell:=Range("S" & i)
Next i

End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks Michael, your solution didn't quite work for me (it froze my system, or perhaps it was calculating all those goal seeks?!) - the screenupdating = false made me unsure. but you gave me an idea:

Sub GoalSeek_Range()
For j = 2 To 19698
Cells(j, "T").GoalSeek Goal:=0.4, ChangingCell:=Cells(j, "S")
Next j
End Sub
 
Last edited:
Upvote 0
Glad it worked. Yes, that was a lot of cells to process. I was not sure how long it would take.
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

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