Assumed we have this simple macro code for goal seek a value:
oGoal = seekGoal(oFormulaCell.CellAddress, oVariableCell.CellAddress, "20")
Would it be possible to replace the current value "20"
with the value taken from a cell, e.g. taken from the cell oTargetValueCell.CellAddress
?
I would love to use something like:
oGoal = seekGoal(oFormulaCell.CellAddress, oVariableCell.CellAddress, oTargetValueCell.CellAddress)
If it may help, here you can see the whole current (working) macro code:
Sub Goalseek
Dim Sheet2
Dim oFormulaCell
Dim oTargetValueCell
Dim oVariableCell
Dim oGoal
oSheet = ThisComponent.Sheets(0)
oFormulaCell = oSheet.getCellRangeByName("A1")
oTargetValueCell = oSheet.getCellRangeByName("A2")
oVariableCell = oSheet.getCellRangeByName("A3")
oGoal = ThisComponent.seekGoal(oFormulaCell.CellAddress, oVariableCell.CellAddress, "20")
oTargetCell.setValue(oGoal.Result)
End Sub