簡體   English   中英

LibreOffice Calc Goal Seek 在基本宏中不起作用

[英]LibreOffice Calc Goal Seek does not work from Basic Macro

我正在嘗試從 Calc Basic Macro 中進行目標搜索。

Public Sub Goal_Seek()
  oVariableCell = detailSheet.getCellRangeByName("VariableCell")
  oFormulaCell = detailSheet.getCellRangeByName("FormulaCell")
  oTargetCell = detailSheet.getCellRangeByName("TargetCell")
  ThisComponent.seekGoal(oFormulaCell.CellAddress, oVariableCell.CellAddress, oTargetCell.getValue)
End Sub

當我運行宏時,沒有任何更新。 當我從電子表格菜單 Tools->Goal Seek 運行 Goal Seek 並在表單中輸入相同的單元格時,目標搜索功能正常。

我的宏在我的宏標准模塊 1 中。 命名范圍返回正確的單元格地址。 當從宏調用時,什么可能導致目標尋求不更新?

它不起作用的原因是當我從宏調用目標集時,我必須自己設置結果。 我應該猜到的。 新代碼是

  detailSheet = ThisComponent.Sheets(7)
  oVariableCell = detailSheet.getCellRangeByName("VariableCell")
  oFormulaCell = detailSheet.getCellRangeByName("FormulaCell")
  oTargetCell = detailSheet.getCellRangeByName("TargetCell")
  oGoal = ThisComponent.seekGoal(oFormulaCell.CellAddress, oVariableCell.CellAddress, oTargetCell.getValue)
  oVariableCell.setValue(oGoal.Result)
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM