Compile Error Sub Not Defined Solver
Contents |
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers compile error sub or function not defined solver Retired content Samples We’re sorry. The content you requested has been removed.
Compile Error Sub Or Function Not Defined Vba
You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related compile error sub or function not defined in excel macro threads Remove From My Forums Answered by: Sub or Function not defined Microsoft ISV Community Center > Visual Basic for Applications (VBA) Question 1 Sign in to vote I came accross a compile error sub or function not defined access strange problem. I tried to record a macro where I used Solver. After I tried to run it, I was given an error message: Compile Error: Sub or Function not defined. The function where VBA stops is "SolverOK". It is not a macro that I coded, I recorded it in the excell sheet. Thanks for any advice. Lubomir -------------------------------------------------------------------------- Code
Compile Error Sub Or Function Not Defined Excel 2010
that was generated is obviously correct: Sub solver()' solver Macro' Macro recorded 26/07/2007 by Z05041K SolverOk SetCell:="$B$115", MaxMinVal:=3, ValueOf:="0", ByChange:="$B$91" SolverSolveEnd Sub Thursday, July 26, 2007 9:27 AM Reply | Quote Answers 2 Sign in to vote Hi,You need to include a reference to SOLVER.XLAWith VBE use menu Tools > References. Check the Solver reference. Proposed as answer by ryguy72 Saturday, August 09, 2014 2:28 PM Marked as answer by danishaniModerator Tuesday, September 16, 2014 5:30 AM Thursday, July 26, 2007 6:10 PM Reply | Quote All replies 2 Sign in to vote Hi,You need to include a reference to SOLVER.XLAWith VBE use menu Tools > References. Check the Solver reference. Proposed as answer by ryguy72 Saturday, August 09, 2014 2:28 PM Marked as answer by danishaniModerator Tuesday, September 16, 2014 5:30 AM Thursday, July 26, 2007 6:10 PM Reply | Quote 0 Sign in to vote I have the same problem. OK, found this in VB Help SolverOk Function Defines a basic Solver model. Equivalent to clicking Solver on the Tools menu and then specifying options in the Solver Parameters dialog box. Before you use this funct
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us solver compile error in hidden module Learn more about Stack Overflow the company Business Learn more about hiring developers solver vba no dialog box or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow
Solverok Compile Error
Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Excel VBA: Compile Error: Sub of Function not https://social.msdn.microsoft.com/Forums/en-US/2a0a5859-b688-42f5-a953-97fd9f85d4c8/sub-or-function-not-defined?forum=isvvba Defined up vote 1 down vote favorite I'm trying to solve a problem with the following code but I just can't find a way around it. Whenever I try the Macro, I get an error "Sub or Function not defined". and the debugger highlights in yellow "Sub Solver_Overtime() and highlights in blue "SolverRest" Sub Solver_OverTime() Application.ScreenUpdating = False Sheets("OverTime").Activate SolverReset SolverOptions MaxTime:=100, _ Iterations:=100, _ Precision:=0.000001, _ http://stackoverflow.com/questions/21915646/excel-vba-compile-error-sub-of-function-not-defined AssumeLinear:=True, _ StepThru:=False, _ Estimates:=1, _ Derivatives:=1, _ SearchOption:=1, _ IntTolerance:=5, _ Scaling:=False, _ Convergence:=0.0001, _ AssumeNonNeg:=True SolverAdd CellRef:="NET", Relation:=3, FormulaText:="NET_LIMIT" SolverAdd CellRef:="shftCount", Relation:=1, FormulaText:="shftCountLimit" SolverAdd CellRef:="schTemplate", Relation:=4, FormulaText:="integer" SolverOk setcell:=Sheets("OverTime").Range("Intervals[[#Totals],[OT]]"), MaxMinVal:=2, ValueOf:="0", ByChange:=Sheets("OverTime").Range("Template_Schedule[COUNT]") 'SolverOk SetCell:="TargetCell", MaxMinVal:=2, ValueOf:="0", ByChange:="schTemplate" SolverSolve True End Sub I'm not certain what the problem is because it runs just fine on another computer. Thanks in advance. excel vba excel-vba share|improve this question asked Feb 20 '14 at 17:48 BlueSun3k1 1863620 4 Did you add a reference to the Solver library? (Tools>References>Solver) –Tim Williams Feb 20 '14 at 17:56 @pnuts that was a typo, it's SolverReset. –BlueSun3k1 Feb 20 '14 at 18:01 1 @Tim Williams: I did not but now I did and it works. Thank you, that takes care of the issue. –BlueSun3k1 Feb 20 '14 at 18:01 1 @user1582396 do make it an answer and accept it please. –nawfal Sep 22 '14 at 13:14 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted I followed up on Tim William's instructions to add a Reference to the Solver Library by going to Tools > References > Solver. It did the job and it wor
Forums Excel Questions Compile Error When Running VBA Solver Results 1 to 3 of 3 http://www.mrexcel.com/forum/excel-questions/545612-compile-error-when-running-visual-basic-applications-solver.html Compile Error When Running VBA SolverThis is a discussion on http://peltiertech.com/Excel/SolverVBA.html Compile Error When Running VBA Solver within the Excel Questions forums, part of the Question Forums category; Can anyone help? I keep receiving a Compile Error: Sub or Function not defined when I try to run a ... LinkBack LinkBack compile error URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Apr 23rd, 2011,02:04 AM #1 SteveFrancis New Member Join Date Apr 2011 Posts 2 Compile Error When Running compile error sub VBA Solver Can anyone help? I keep receiving a Compile Error: Sub or Function not defined when I try to run a macro that runs solver. The Sub RunSolverLibContent() ' ' RunSolverLibContent Macro ' ' SolverOk SetCell:="$F$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$F$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverOk SetCell:="$F$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$F$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverSolve SolverOk SetCell:="$G$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$G$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverOk SetCell:="$G$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$G$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverSolve SolverOk SetCell:="$H$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$H$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverOk SetCell:="$H$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$H$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverSolve SolverOk SetCell:="$I$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$I$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverOk SetCell:="$I$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$I$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverSolve SolverOk SetCell:="$J$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$J$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverOk SetCell:="$J$32", MaxMinVal:=3, ValueOf:=0, ByChange:="$J$35", Engine _ :=1, EngineDesc:="GRG Nonlinear" SolverSolve Sheets("Forecasted Drivers").Select Range("A34").Select End Sub Share Share this post on Di
Use Solver Links Solver and Conventional VBA Solver is a powerful analysis tool, bundled with Excel and used for optimization and simulation of business and engineering models. It can be even more powerful if used in conjunction with VBA, to automate solving of multiple models which use different input parameters and constraints. In a simple example, there are two factors in B5 and B6. The product (=B5*B6) is calculated in B8. Solver will be used to find the maximum value of the target cell (the product in B8), subject to the constraint that both factors (B5:B6) shall not exceed a value of 4. Select Solver from the Tools menu, and enter the appropriate conditions and constraints in the Solver Parameters dialog. Click the Solve button, and another dialog indicates whether a solution is found and offers some options. If you record a macro while you use Solver, you will get something like the following: Sub SolverMacro1() ' ' SolverMacro1 Macro ' Macro recorded by Jon Peltier ' SolverOk SetCell:="$B$8", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$5:$B$6" SolverAdd CellRef:="$B$5:$B$6", Relation:=1, FormulaText:="4" SolverOk SetCell:="$B$8", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$5:$B$6" SolverSolve End Sub SolverAdd adds constraints to the Solver model. SolverOK defines the cell to optimize, how to optimize it, and what cells to change during the Solver optimization. The macro recorder wrote this line twice, so the first occurrence can be removed. To prevent parameters from a different Solver optimization interfering with the macro's optimization, Solver should be reset prior to running, using SolverReset. SolverSolve has an optional UserFinish argument; if UserFinish is False or omitted, the second dialog shown above will ask the user whether to save the optimization, but if UserFinish is True, Solver will e