Sub GoalSeeker()
Dim rgVals As Range, rgReport As Range, celGoal As Range, celVary As Range
Dim i As Long, n As Long
Dim dGoal As Double
dGoal = 1
With Worksheets("Sheet1")
Set rgVals = .Range("E6:E11")
Set celGoal = .Range("E19")
Set celVary = .Range("E18")
End With
Set rgReport = Worksheets("Sheet 2").Range("C3:H3")
Set rgReport = rgReport.End(xlDown).Resize(1, rgReport.Columns.Count)
Application.ScreenUpdating = False
For i = 1 To 1000
celGoal.GoalSeek dGoal, celVary
rgReport.Rows(i + 1).Value = Application.Transpose(rgVals.Value)
Next
Application.ScreenUpdating = True
End Sub
|