stepping through rows using offset function

staderennais

New Member
Joined
Jul 13, 2007
Messages
3
Hi,
I've done some programming but I'm completely new at VBA. I searched the archives but couldn't find a direct example or answer to my question. I apologize if this is a dumb question.

I'm trying to solve a nonlinear equation using goal seek. The output from that equation is then being used in an optimization routine. The point is that I need goalseek to update the row every time before the solver runs another iteration. However, I keep getting this error:

"Run time error '1004' "

Here's my code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim M As Integer

For M = 0 To 99

Worksheets("Sheet1").Range("Offset(j7, M, 0, 1, 1)").GoalSeek _
Goal:=0, _
ChangingCell:=Worksheets("Sheet1").Range("Offset(i7, M, 0, 1, 1)")

Next M

End Sub




Thanks for any help you can offer.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
See if this does what you need


Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
Dim M As Integer 

For M = 0 To 99 

Worksheets("Sheet1").Range("J7").Offset(M, 0).GoalSeek _ 
Goal:=0, _ 
ChangingCell:=Worksheets("Sheet1").Range("I7").Offset(M, 0) 

Next M 

End Sub
Offset is used a bit different with code.
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,904
Members
449,194
Latest member
JayEggleton

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