My name is Bo and I am using solver to solve my minimization problem in a loop in vba. I have set everything up and press F8 to go step by step. When I got the solversolve, it doesn't update the cell. And everytime after I ran the solversolve process, the formula calculation will be set to manual automatically and I need to change it back to automatic calculation everytime I went through solversolve. There are no errors popping up. It just doesn't have any effect on the spreadsheet. When I used the same setting and use the solver add-in by hand, it could update the cell. It just doesn't work in VBA. It will be appreciated if anyone could solve the problem. My code is :
Sheets("Temp").Select
Solverreset
Sure, the attached file is my excel file. The work is in the sheet's name of "Temp" and the code is in Module one.I have got rid of other sheets and some code not involved in the solversolve so that it could be small enough to upload. Please let me know if you could find something wrong in it. Thanks!
Thank you Alf. I have used the code you used and it could run and give me the same error. Then I open solver add-in in excel and run it by hand, it could find the optimum answer and no error popping up. There is a picture of my solver setting. It will be great if you could help find the consistency between the program and the code. SolverSetting.jpg
When setting up a solver model for the first time I would advice against using the "SolverSolve Userfinish:=True" command as Solver will then ignore any warnings about problems with the model but just present a "solution / result" right or wrong.
Bookmarks