Ottsel
Board Regular
- Joined
- Jun 4, 2022
- Messages
- 174
- Office Version
- 365
- Platform
- Windows
Trying to construct a loop that'll use the Goal Seek function within excel. Instead of doing one at a time I'm attempting to do 10 at a time within a for loop.
Here's what I have so far, but I'm unsure where my error is:
Description:
AC12:AC20 have amounts that need to change.
AR12:AR20 have current percentages. These change depending on what is within the AC column
Inputbox is where I enter my changing amount.
Example:
Range.AR12 = -14.2%
I wish to change this to -8%
Range.AC12 = 1,200
Now, entering -8% will change Range.AC12 to 2,386
My goal is to find the value for all 10 rows to see what the amounts will be at -8% or any amount for that matter.
Also, formulas do not work here, thus VBA is required or the GoalSeek Function within the Data Tab.
Any help, tips or tricks would be greatly appreciated - thank you!
Here's what I have so far, but I'm unsure where my error is:
VBA Code:
Sub NewAdjustments()
Dim CellChng As Integer
Dim i As Integer
CellChng = InputBox("Please input the desired adjustment.")
If CellChng = "" Then
Exit Sub
End If
Application.CutCopyMode = False
'...Plan 1
For i = 12 To 20
Range("AR & i").GoalSeek Goal:=CellChng, ChangingCell:=Range("AC & i")
Next i
End Sub
Description:
AC12:AC20 have amounts that need to change.
AR12:AR20 have current percentages. These change depending on what is within the AC column
Inputbox is where I enter my changing amount.
Example:
Range.AR12 = -14.2%
I wish to change this to -8%
Range.AC12 = 1,200
Now, entering -8% will change Range.AC12 to 2,386
My goal is to find the value for all 10 rows to see what the amounts will be at -8% or any amount for that matter.
Also, formulas do not work here, thus VBA is required or the GoalSeek Function within the Data Tab.
Any help, tips or tricks would be greatly appreciated - thank you!