Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


Keywords: KB213689, kbprogramming, kbpending, kberrmsg, kbbug

↑ Back to the top

Article Info
Article ID : 213689
Revision : 8
Created on : 1/24/2007
Published on : 1/24/2007
Exists online : False
Views : 395