Hello All,
I am having a bit of a problem with the syntax of a Goal Seek Command in a macro and would certainly appreciate any assistance. I have 30 cells which may trigger a goal seek if a certain value is above 0. The cells I am checking for the value > 0 are in D138 thru AE138. The goal and change value are relative to this item (within the same column - target is 8 rows below and change value is 6 rows above). My code is as follows:
Dim myRnge As Range
Set myRnge = Range("D130:AF130")
For Each cell In myRnge
If cell.Offset(8, 0) > 0 Then
cell.GoalSeek Goal:=cell.Offset(8, 0), ChangingCell:=cell.Offset(-6, 0)
End If
Next cell
When this macro is run, the message I receive is a "Run-Time Error 1004" Reference is not valid.
Thanks in advance for your help.
CDawg
I am having a bit of a problem with the syntax of a Goal Seek Command in a macro and would certainly appreciate any assistance. I have 30 cells which may trigger a goal seek if a certain value is above 0. The cells I am checking for the value > 0 are in D138 thru AE138. The goal and change value are relative to this item (within the same column - target is 8 rows below and change value is 6 rows above). My code is as follows:
Dim myRnge As Range
Set myRnge = Range("D130:AF130")
For Each cell In myRnge
If cell.Offset(8, 0) > 0 Then
cell.GoalSeek Goal:=cell.Offset(8, 0), ChangingCell:=cell.Offset(-6, 0)
End If
Next cell
When this macro is run, the message I receive is a "Run-Time Error 1004" Reference is not valid.
Thanks in advance for your help.
CDawg