Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro/Solver error message question
Hi, I am using Excel97. I recorded a very simple macro involving
Solver. When running this recorded macro I get an error message: Compile error Sub or function not defined Apparently the offending statement is SolverOK, which is the first statement in the sub. Since Excel itself recorded the macro, I don't know what to do about this. Any help or ideas? Many thanks in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro/Solver error message question
You have to set a reference to solver before you execute those statements.
http://support.microsoft.com/default...b;en-us;843304 How to create Visual Basic macros by using Excel Solver in Excel 97 If doing it locally, you can do it manually. If you will be distributing it, Dana Delouise posted this code in the past: Sub SolverInstall() '// Dana DeLouis Dim wb As Workbook On Error Resume Next ' Set a Reference to the workbook that will hold Solver Set wb = ActiveWorkbook With wb.VBProject.References .Remove .Item("SOLVER") End With With AddIns("Solver Add-In") .Installed = False .Installed = True wb.VBProject.References.AddFromFile .FullName End With End Sub -- Regards, Tom Ogilvy " wrote: Hi, I am using Excel97. I recorded a very simple macro involving Solver. When running this recorded macro I get an error message: Compile error Sub or function not defined Apparently the offending statement is SolverOK, which is the first statement in the sub. Since Excel itself recorded the macro, I don't know what to do about this. Any help or ideas? Many thanks in advance. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro/Solver error message question
Tom Ogilvy wrote: You have to set a reference to solver before you execute those statements. http://support.microsoft.com/default...b;en-us;843304 How to create Visual Basic macros by using Excel Solver in Excel 97 If doing it locally, you can do it manually. If you will be distributing it, Dana Delouise posted this code in the past: Sub SolverInstall() '// Dana DeLouis Dim wb As Workbook On Error Resume Next ' Set a Reference to the workbook that will hold Solver Set wb = ActiveWorkbook With wb.VBProject.References .Remove .Item("SOLVER") End With With AddIns("Solver Add-In") .Installed = False .Installed = True wb.VBProject.References.AddFromFile .FullName End With End Sub -- Regards, Tom Ogilvy Very helpful, Tom, I really appreciate it. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
what does error message "too many adjustable cells" mean in solver | Excel Discussion (Misc queries) | |||
get error message when I try to post a question | Excel Discussion (Misc queries) | |||
Solver val error message | Excel Discussion (Misc queries) | |||
Interesting Solver problem (Solver encounters an error) | Excel Discussion (Misc queries) | |||
Error message when using the Solver in a VBA macro loop | Excel Programming |