Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro doesn't work in Excel 2010 1

Status
Not open for further replies.

rammo123

Technical User
Dec 22, 2011
3
NZ
I am very much a VBA noob. I have created a simple macro that automatically uses solver to find a solution to a problem. The macro works fine on my workstation, but when I try to use it on a computer with Excel 2010 installed, the output value always resets to 0. Any suggestions?
 

Well, it would be nice to actually see the code.

Have fun.

---- Andy
 
There are some significant differences between Solver-2010 and its predecessors. See, for example, thread707-1648983 which points out the different default conditions regarding a variable's allowable values.

 
Here is the code. I've had a look around the web and I'm sure it's something to do with referencing solver.xlam.

Sub Solve_DewPoint()

'Solve_DewPoint Macro

Range("B4").Value = -5
SolverReset
SolverOk SetCell:="$F$22", MaxMinVal:=2, ByChange:="$B$4"
SolverSolve True

End Sub

 
I do not think you will get ANY answer if you've failed to reference Solver.xlam correctly. You say you are getting a result of 0.0 under Excel-2010, which is different from what you used to get under earlier versions.

If my hunch (as outlined above) is correct, you will need to add a line along the lines of
Code:
SolverOptions AssumeNonNeg:=False
in your macro.

You do not say what the correct answer ought to be. If it is a negative answer then that would add further evidence to my suggestion.
 
I tried the assumeNonNeg thing after reading your other thread. It was relevant as my results are often negative, but did not seem to help.

However, when I re-recorded the macro but omitted the SolverReset function, the macro works perfectly. It was this function that seemed to be throwing the spanner in the works.

I don't really need SolverReset, but it would be nice to know why it throws it's toys out of the cot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top