Repeating simple macro from row 10 to row 1000

lisavonseth

New Member
Joined
Sep 29, 2009
Messages
4
I have a very easy macro written - but haven't been able to repeat it for a range of lines.

here is the macro for line 10
Range("AJ10").GoalSeek Goal:=Range("AK10"), ChangingCell:=Range("AI10")

Then I want to give the command "repeat for lines 10 to 1000"

Anyone who knows how to do this????
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello and welcome to MrExcel.

Try

Code:
Sub glseek()
Dim i As Integer
For i = 10 To 1000
    Range("AJ" & i).GoalSeek Goal:=Range("AK" & i), ChangingCell:=Range("AI" & i)
Next i
End Sub
 
Upvote 0
Great!
This is how my Macro looks now. How do I modify to capture the Dim as you mention ? Can you maybe show in my Macro below ? So I know how to modify ?


Sub LISA()
'
' LISA Macro
'
' Keyboard Shortcut: Ctrl+Shift+Z
'
Range("AJ10").GoalSeek Goal:=Range("AK10"), ChangingCell:=Range("AI10")
End Sub
 
Upvote 0
Try

Code:
Sub LISA()
'
' LISA Macro
'
' Keyboard Shortcut: Ctrl+Shift+Z
'
Dim i As Integer
For i = 10 To 1000
    Range("AJ" & i).GoalSeek Goal:=Range("AK" & i), ChangingCell:=Range("AI" & i)
Next i
End Sub
 
Upvote 0
Tried that and got message :

Run-time Error '1004'

Method 'Range' of object '_Global' failed


Here is copy of macro:
Sub LISA()
'
' LISA Macro
'
' Keyboard Shortcut: Ctrl+Shift+Z
'
Dim i As Integer
For i = 10 To 1000
Range("AJ & i").GoalSeek Goal:=Range("AK & i"), ChangingCell:=Range("AI & i")
Next i
End Sub
 
Upvote 0
You have " in the wrong place. Copy and paste

Code:
Range("AJ" & i).GoalSeek Goal:=Range("AK" & i), ChangingCell:=Range("AI" & i)
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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