Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I created a macro that uses Solver by recording one, selecting solver as a
VBA reference, and changing the target value from a number to a cell reference. In the spreadsheet, cell A3 = A1*A2. Cells A1 and A2 simply contain values. C1 contains the number that Solver should use as the target value. Here's the macro code€¦ Sub Macro2() ' ' Macro2 Macro SolverOk SetCell:="$A$3", MaxMinVal:=3, ValueOf:="C1", ByChange:="$A$2" SolverSolve End Sub First problem is that the solver runs successfully on the first occasion the macro is run, but running the macro after changing the number in C1 creates erroneous output. The reason seems to be that Solver contains target number from the first occasion. I think this because when I open the Solver dialogue box, it contains references from the first occasion. Is there a need for a line of code that somehow resets Solver? Second problem is I would like to modify the code to automatically accept the output Solver finds, regardless of whether it succeeded in finding a solution or not. How do I change the code to do that please? Finally, the Solver constraints did not appear in the macro that was recorded. Where can I find information about coding constraints into the macro please? TIA €¦. Greg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Programming Solver | Excel Programming | |||
Solver programming in VBA | Excel Programming | |||
Linear Programming(solver ?) | Excel Programming | |||
Programming Questions | Excel Programming | |||
SOLVER- programming or not? | Excel Programming |