0

I have the following snippet of Excel VBA code to solve a minimisation problem:

SolverOk SetCell:="$AP$13", MaxMinVal:=2, ValueOf:=0, ByChange:="$AP$9:$AP$11", Engine:=1
SolverSolve UserFinish:=True

This was created using the "record macro" menu command in Excel. If I run the problem from the menu bar using Data | Solver then Solver happily changes all three cells and completes the problem. The same happens if I run the macro from EXCEL (using Alt-F8). However, I have assigned the same macro to a VBA button and when I press this Excel only changes cell A9. I get the same issue if I change the code to

SolverOk SetCell:="$AP$13", MaxMinVal:=2, ValueOf:=0, ByChange:="$AP$10:$AP$11", Engine:=1

I tried resetting the problem using SolverReset but this produces an error saying Excel has been exhausted.

Would appreciate any suggestions on how to force Excel to change all three cells, not just cell A9

Thanks!

1 Answer 1

0

This problem has been modified and updated here:

EXCEL VBA does not run SOLVER inside a macro invoked from a chart button

to avoid problems with chameleon questions

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.