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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

lisavonseth

New Member
Joined
Sep 29, 2009
Messages
4
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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

lisavonseth

New Member
Joined
Sep 29, 2009
Messages
4
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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
You have " in the wrong place. Copy and paste

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

lisavonseth

New Member
Joined
Sep 29, 2009
Messages
4
Wonderfull !

Well spotted ! :)

THANX Peter - you just saved me LOADS of work !

have a great day !!!!
 

Forum statistics

Threads
1,186,105
Messages
5,955,862
Members
438,222
Latest member
nalij_bond

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
Top