Compile Error Sub Or Function Not Defined Excel 2007 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 Retired content Samples We’re sorry. The content compile error sub or function not defined excel vba you requested has been removed. You’ll be auto redirected in 1 second. Ask a question
Compile Error Sub Or Function Not Defined Excel 2010
Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Sub or Function not
Excel Macro Compile Error Sub Or Function Not Defined
defined Microsoft ISV Community Center > Visual Basic for Applications (VBA) Question 1 Sign in to vote I came accross a strange problem. I tried to record a macro where I used Solver. After I tried
Compile Error Sub Or Function Not Defined Access
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 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 compile error sub or function not defined vba 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 function, you must establish a reference to the Solver add-in. With a Visual Basic module active, click References on the Tools menu, and then select the Solver.xla check box under Available References. If Solver.xla doesn't appear under Available References, click Browse and open Solver.xla in the \Office\Library\S
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 Learn more about Stack compile error sub or function not defined solver macro Overflow the company Business Learn more about hiring developers or posting ads with us solver vba no dialog box Super User Questions Tags Users Badges Unanswered Ask Question _ Super User is a question and answer site for computer enthusiasts and solverok compile error power users. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Excel https://social.msdn.microsoft.com/Forums/en-US/2a0a5859-b688-42f5-a953-97fd9f85d4c8/sub-or-function-not-defined?forum=isvvba VBA Macro Sub or Function not defined up vote 1 down vote favorite I used the macro recorder to generate a macro in Excel 2007. When I try to the run the macro, it tells me: When I click Ok the definition of the macro gets highlighted. I'm really confused about why VBA would throw this error. I just defined it! Do you have any ideas what I did wrong? microsoft-excel microsoft-excel-2007 http://superuser.com/questions/264257/excel-vba-macro-sub-or-function-not-defined macros vba share|improve this question edited Mar 7 '12 at 14:29 Raystafarian 17k94378 asked Mar 30 '11 at 1:07 wdkrnls 3451516 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote accepted 1st - check if there's no missing reference in the VBA project. 2nd - It seems it needs the Solver Addin. Ensure it's checked in Excel Addins. share|improve this answer answered Mar 30 '11 at 1:34 Tiago Cardoso 23615 I'll check this out. I didn't think about references. Hopefully that is it. Thanks. –wdkrnls Mar 30 '11 at 6:58 You were right. I didn't add Solver to the references for the project. Thanks. –wdkrnls Mar 31 '11 at 20:55 add a comment| up vote 2 down vote This answer is pretty late (I'm a new arrival to SuperUser). You need to go to VBA editor screen, choose References... from the Tools menu, find Solver and check the box to allow VBA to use Solver references in your code. share|improve this answer answered Mar 4 '14 at 13:24 joseph.billo 212 add a comment| up vote 0 down vote I had the same problem. I copied my code and created another module. Right clicking Module1 in the Project Tree, I used the "Module1 properties" to ch
> Operating Systems > Apple Macintosh > Mac Office > Mac Office Excel > How to run solver from a macro How to run solver from a macro Posted: 09-12-2007, 03:10 PM http://www.realgeek.com/forums/how-to-run-solver-from-a-macro-405907.html Skin Paul Guest Posts: n/a Show Printable Version Email this Page Post Comment Hi all, Using xl 2004 v.11.3.5 - Mac OS 10.4.10 I am trying to run solver from a macro but not having http://peltiertech.com/Excel/SolverVBA.html much luck. If I select solver from the menu and input the right info and click solve It works fine. When I run solver via a macro I get a compile error - Sub or Function compile error not defined.Below is where I"m at. Any pointers to my mistake please. Sub Solve() SolverOk SetCell:="$G$18", MaxMinVal:=3, ValueOf:="510", ByChange:="$C$18" SolverSolve End Sub SolverOk Gets highlighted but I don't know what next to do. Thanks Paul How to run solver from a macro Responses to "How to run solver from a macro" Skin Paul JE McGimpsey Guest Posts: n/a Re: How to run solver from a macro Posted: 09-12-2007, 05:08 PM In compile error sub article
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 end without the dialog. A modified Solver macro is shown below: Sub SolverMacro2() ' ' SolverMacro2 Macro ' Macro fixed up by Jon Peltier ' SolverReset SolverAdd CellRef:="$B$5:$B$6", Rela