→ kimutaka:那天說得不清楚 恭喜你後來自己解決了 02/28 15:30
※ 引述《A1pha ([αλφα])》之銘言:
: 大大,好像不行也,
: 後來我改寫成如下,
: 但是他還是顯示,
: 沒有定義這個SUB或Function。
: 根據他標示的來看,
: 他好像完全不知到SolverOK是什麼東西...囧
: 還沒讀到限制式就掛點了....QQ
: Sub Macro4()
: '
: SolverOk SetCell:="$AH$2", MaxMinVal:=1, ValueOf:="0",
: ByChange:="$AF$4:$AF$30"
: SolverAdd CellRef:="$AA$2", Relation:=2, formulaText:="$U$2"
: SolverAdd CellRef:="$AE$2", Relation:=2, formulaText:="$B$2"
: SolverAdd CellRef:="$AF$4:$AF$30", Relation:=4, formulaText:="=integer"
: SolverAdd CellRef:="$AF$4:$AF$30", Relation:=2,
: formulaText:="$AA$4:$AA$30"
: SolverAdd CellRef:="$AF$4:$AF$30", Relation:=1, formulaText:="0"
: SolverAdd CellRef:="$V$2", Relation:=2, formulaText:="$R$2"
: SolverAdd CellRef:="$W$2", Relation:=2, formulaText:="$S$2"
: SolverOptions MaxTime:=100, Iterations:=100, Precision:=0.000001,
: AssumeLinear:=False, StepThru:=False, Estimates:=1, Derivatives:=1,
: SearchOption:=1, _
: IntTolerance:=0.005, scaling:=False, Convergence:=0.0001,
: AssumeNonNeg:=True
: SolverSolve UserFinish:=True
: SolverFinish keepFinal:=1
: SolverReset
XD
後來我跑去FaceBook的EXCEL粉絲團問老外~
結果找到解答了XD
===========
Excel Spreadsheets寫到:
You need to create a reference to the Solver add-in in the VBA editor. To do
this, open up the VBA editor go to the module where the macro is. Then choose
Tools > References and check the box which says "SOLVER". The macro will then
run.
You should also add "SolverReset" at the beginning of the macro to clear out
any existing Solver instances within the spreadsheet.
===========
簡單說,
假使要使用「規劃求解」的巨集的話,
要先把引用的項目打開,
概念有點像是要先啟用Library,這樣程式才會看的懂那些字。
要開規劃求解的字典的話,
先到VBA視窗去,
先點到該巨集的所在的模組,
然後在「工具」選項那邊有個「設定引用項目」,
點那個進去之後,
把SOLVER選項打勾,就可以用了~
希望有相同問題的板友,
能藉此順利找到解答 :D
--
據聞,椅子在聽說Money Ball要拍成電影後如是回應:
我椅子,就在這個moment,要爆啦!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.194.88.67