![]() |
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. |
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. |
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. |
All times are GMT +1. The time now is 06:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com