Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what does error message "too many adjustable cells" mean in solver dee Excel Discussion (Misc queries) 1 August 27th 09 03:43 AM
get error message when I try to post a question kirk Excel Discussion (Misc queries) 0 July 20th 09 06:32 PM
Solver val error message Box815 Excel Discussion (Misc queries) 0 January 4th 07 07:16 PM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM
Error message when using the Solver in a VBA macro loop Mathieu Fournier Excel Programming 2 March 1st 05 02:36 PM


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"