I'm trying to use Libre Office Basic to write user defined function for Libre Office Calc which runs Goal Seek as a function instead of me going to the menu and clicking.
What I want to be able to do is pass a cell as the first argument for the formula, the second argument to be the value I want to set the formula to, and the third argument to be the cell which contains the variable to be manipulated.
So for instance I want to type in cell A3 in calc =GSeek2(A1,5,A2)
where A1 contains =A2 + 1
and A2 starts as 0 and have A3 equal to 4.
I think the formula and the cell to be manipulated need to be passed through the Goal Seek function as an address, but I'm not sure. I've tries the following code, but I keep getting "BASIC syntax error. Unexpected symbol: Goal." Anyone know where I'm going wrong?
Function GSeek2(Form As Range, Target as Double, Var as Range)
Form = Form.Address
Var = Var.Address
With Worksheets("Sheet1")
GSeek2 = .Range(Form).GoalSeek _
Goal:=.Value(Target).Value, _
ChangingCell:=.Range(Var)
End With
End Function
Value
property – Tim Williams.Value
bit and replacing it withGoal:=5
I still get the same error: "BASIC syntax error. Unexpected symbol: Goal." – Brian Albert Monroe