I need a little assistance with a code that I am writing for one of my worksheets. Here is what I am trying to do:
1. loop through each row 1-200
2. If the cell in column "Z" is > 0 then
3. Goalseek the cell in column "AS" of the same row to 0.25 by changing the cell in column "X" of the same row.
note: each row is looked at independently.
Here is the code I have started, but I keep getting an error on the goalseek line.
error: "Method 'Range' of Object'_Global' Failed
Thanks for the assistance.
Randy
Sub VC_Calc()
Dim Price As Range
Dim Cell As Range
Set Price = Range("Z1:Z200")
For Each Cell In Price
With Cell
If Cells(.Row, "Z").Value > 0 Then
Range(.Row, "AS").GoalSeek Goal:=0.25, ChangingCell:=Range(.Row, "X")
End If
End With
Next Cell
End Sub
1. loop through each row 1-200
2. If the cell in column "Z" is > 0 then
3. Goalseek the cell in column "AS" of the same row to 0.25 by changing the cell in column "X" of the same row.
note: each row is looked at independently.
Here is the code I have started, but I keep getting an error on the goalseek line.
error: "Method 'Range' of Object'_Global' Failed
Thanks for the assistance.
Randy
Sub VC_Calc()
Dim Price As Range
Dim Cell As Range
Set Price = Range("Z1:Z200")
For Each Cell In Price
With Cell
If Cells(.Row, "Z").Value > 0 Then
Range(.Row, "AS").GoalSeek Goal:=0.25, ChangingCell:=Range(.Row, "X")
End If
End With
Next Cell
End Sub