Goalseek - loop range

A

al

Could someone pls correct/improve my macro - thxs



Sub Goal_SeekRANGt()


TargetVal = Range("Setcell").Offset(0, 1).Resize(1, 12).Address

DesiredVal = Range("Changedto").Offset(0, 1).Resize(1, 12).Address

ChangeVal = Range("ByChanging").Offset(0, 1).Resize(1, 12).Address

' Loop through the goalseek method
For i = 1 To TargetVal.Columns.Count
TargetVal.Cells(i).GOALSEEK Goal:=DesiredVal.Cells(i).Value,
ChangingCell:=ChangeVal.Cells(i)
Next i
End Sub
 
C

CoRrRan

al said:
Could someone pls correct/improve my macro - thxs



Sub Goal_SeekRANGt()


TargetVal = Range("Setcell").Offset(0, 1).Resize(1, 12).Address

DesiredVal = Range("Changedto").Offset(0, 1).Resize(1, 12).Address

ChangeVal = Range("ByChanging").Offset(0, 1).Resize(1, 12).Address

' Loop through the goalseek method
For i = 1 To TargetVal.Columns.Count
TargetVal.Cells(i).GOALSEEK Goal:=DesiredVal.Cells(i).Value,
ChangingCell:=ChangeVal.Cells(i)
Next i
End Sub

*******************************
Sub Goal_SeekRANGt()

Dim rngTarget As Range, rngDesired As Range, rngChange As Range

Dim i As Integer

Set rngTarget = Range("Setcell").Offset(0, 1).Resize(1, 12)
Set rngDesired = Range("Changedto").Offset(0, 1).Resize(1, 12)
Set rngChange = Range("ByChanging").Offset(0, 1).Resize(1, 12)

' Loop through the goalseek method
For i = 1 To rngTarget.Columns.Count

rngTarget.Cells(i).GoalSeek Goal:=rngDesired.Cells(i).Value, _
ChangingCell:=rngChange.Cells(i)

Next i

End Sub
*******************************

CoRrRan
 
A

al

*******************************
Sub Goal_SeekRANGt()

Dim rngTarget As Range, rngDesired As Range, rngChange As Range

Dim i As Integer

Set rngTarget = Range("Setcell").Offset(0, 1).Resize(1, 12)
Set rngDesired = Range("Changedto").Offset(0, 1).Resize(1, 12)
Set rngChange = Range("ByChanging").Offset(0, 1).Resize(1, 12)

' Loop through the goalseek method
For i = 1 To rngTarget.Columns.Count

rngTarget.Cells(i).GoalSeek Goal:=rngDesired.Cells(i).Value, _
ChangingCell:=rngChange.Cells(i)

Next i

End Sub
*******************************

CoRrRan

thxs for your help !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top