Compile error occurs running a recorded macro that uses the Solver add-in (213689)



The information in this article applies to:

  • Microsoft Office Excel 2003
  • Microsoft Excel 2002
  • Microsoft Excel 2000
  • Microsoft Excel 97 for Windows

This article was previously published under Q213689
This article is a consolidation of the following previously available article: 171750

SYMPTOMS

When you run a Visual Basic for Applications macro that you created by using the macro recorder, you may receive the following error message:
Compile error:
Sub or Function not defined.

CAUSE

This behavior can occur when you run a recorded macro that uses the Solver add-in but you do not reference the Solver add-in.

RESOLUTION

To resolve the problem, create a reference to the Solver add-in. To do so, follow these steps:
  1. In Microsoft Excel, start the Visual Basic Editor (press ALT+F11).
  2. On the Tools menu, click References.
  3. Click to select the Solver check box, and then click OK.

    Note If Solver is not in the list of references, make sure that it is enabled. To do this, follow these steps in Excel:
    1. On the Tools menu, click Add-Ins.
    2. Click to select Solver Add-in, and then click OK.
The next time that you run the macro, this behavior does not occur.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

REFERENCES

For more information about using references, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type set a reference to a type library in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbbug kberrmsg kbpending kbProgramming KB213689