VBA Loop with GoalSeek

acorneliuz1213

New Member
Joined
Feb 24, 2023
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Need help with loop, the second Range("AA"..... line needs to be debugged, error message says reference isn't valid. Note i have changed the .Select to .Address and also removed it but it still doesn't work.
Sub GoalSeek_limited()
'
' GoalSeek_limited Macro
'
'
Dim i As Long
For i = 2 To 200
Range("AA" & i).Select
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("AA" & i).GoalSeek Goal:=0.04, ChangingCell:=Range("W" & i).Select
Next

End Sub
-------------------------------
DATA SET:
W X Y Z AA
$6.29 $0.50 $6.79 -68.0%
currently trying to have the macro automate a 4% in AA by plugging in a number in W. I have a ton of data with line breaks all in one tab.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

Avoid all the Select ...
Have you tested
VBA Code:
Sub GoalSeek_limited()
Dim i As Long
For i = 2 To 10
    Range("AA" & i).GoalSeek Goal:=0.04, ChangingCell:=Range("W" & i)
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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