D
Derek Chen
I have a problem with programming Excel solver using vba. I have the
following micro in a workbook named "Book2.xls":
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/8/2005'
SolverOk SetCell:="$H$10", MaxMinVal:=2, ValueOf:="0", ByChange:="$G$10"
SolverAdd CellRef:="$G$10", Relation:=3, FormulaText:="$G$11"
SolverOk SetCell:="$H$10", MaxMinVal:=2, ValueOf:="0", ByChange:="$G$10"
SolverSolve userfinish:=True
End Sub
Macro1 runs fine if I open "Book2.xls" manually and either run it through
"Tools\Macro\Macros...\Macro1 -> Run " or run it in the VB editor.
I then created another workbook named "Test.xls" with the following code.
Private Sub Workbook_Open()
Workbooks.Open Filename:="C:\test\Book2.xls"
End Sub
With this code, I can open "Test.xls" manually, which then automatically
opens "Book2.xls". But when I try to run Macro2 inside "Book2.xls" (either
through "Tools\Macro\Macros...\Macro1 -> Run " or in the VB editor), the
Solver gives me an error "Solver: An unexpected internal error occurred, or
available memory was exhausted".
Does someone have any idea of how to fix this problem?
My original intent was to launch an Excel Workbook from within Microsoft
Access and automatically run the Excel solver with the data exported from
Access (since Access does not have the solver feature). I was given the same
error by the solver when I tried to do so.
following micro in a workbook named "Book2.xls":
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/8/2005'
SolverOk SetCell:="$H$10", MaxMinVal:=2, ValueOf:="0", ByChange:="$G$10"
SolverAdd CellRef:="$G$10", Relation:=3, FormulaText:="$G$11"
SolverOk SetCell:="$H$10", MaxMinVal:=2, ValueOf:="0", ByChange:="$G$10"
SolverSolve userfinish:=True
End Sub
Macro1 runs fine if I open "Book2.xls" manually and either run it through
"Tools\Macro\Macros...\Macro1 -> Run " or run it in the VB editor.
I then created another workbook named "Test.xls" with the following code.
Private Sub Workbook_Open()
Workbooks.Open Filename:="C:\test\Book2.xls"
End Sub
With this code, I can open "Test.xls" manually, which then automatically
opens "Book2.xls". But when I try to run Macro2 inside "Book2.xls" (either
through "Tools\Macro\Macros...\Macro1 -> Run " or in the VB editor), the
Solver gives me an error "Solver: An unexpected internal error occurred, or
available memory was exhausted".
Does someone have any idea of how to fix this problem?
My original intent was to launch an Excel Workbook from within Microsoft
Access and automatically run the Excel solver with the data exported from
Access (since Access does not have the solver feature). I was given the same
error by the solver when I tried to do so.