View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default GoalSeek 1004 Error

No, GoalSeek require a range object as formula reference.

The below is from the xl2000 helpfile.

"Calculates the values necessary to achieve a specific goal. If the goal is
an amount returned by a formula, this calculates a value that, when supplied
to your formula, causes the formula to return the number you want. Returns
True if the goal seek is successful.

Syntax

expression.GoalSeek(Goal, ChangingCell)

expression Required. An expression that returns a Range object. Must be a
single cell.
Goal Required Variant. The value you want returned in this cell.
ChangingCell Required Range. Specifies which cell should be changed to
achieve the target value."

Regards,
Per

"Jason" skrev i meddelelsen
...
Well that brings up a good question. I was writing the value of a
formula
from VBA to that Cell instead of putting the formula itself in the cell

Is it possible to use GoalSeek without referencing a formula in a cell and
instead referencing a formula in VBA?

Example:
Y_F=TestVar1+TestVar1^2...
And use GoalSeek to try and get the formula Y_F down to zero by changing
TestVar1?



"Per Jessen" wrote:

Hi

Nothing seems to be wrong with the line.

What is the error description more than error 1004 ?

Do you have the formula etc. in row 1 column 201:203 ?

Hopes this helps.
....
Per

"Jason" skrev i meddelelsen
...
I am trying to use the GoalSeek function in my VBA, but am unable to get
it
to work, I have been getting 1004 error

Here is the line that seems to cause the 1004 error

Worksheets("Data Sheet").Cells(1, 203).GoalSeek Goal:=Worksheets("Data
Sheet").Cells(1, 201).Value, _
Changingcell:=Worksheets("Data Sheet").Cells(1, 202)

Please let me know if you need more info.

Thank you,


.