Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I used the macro recorder to generate a macro in Excel 2007. When I try to the run the macro, it tells me:

Compile error:  Sub or Function not defined

When I click Ok the definition of the macro gets highlighted.

enter image description here

I'm really confused about why VBA would throw this error. I just defined it! Do you have any ideas what I did wrong?

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted
  • 1st - check if there's no missing reference in the VBA project.
  • 2nd - It seems it needs the Solver Addin. Ensure it's checked in Excel Addins.
share|improve this answer
    
I'll check this out. I didn't think about references. Hopefully that is it. Thanks. –  wdkrnls Mar 30 '11 at 6:58
    
You were right. I didn't add Solver to the references for the project. Thanks. –  wdkrnls Mar 31 '11 at 20:55
add comment

This answer is pretty late (I'm a new arrival to SuperUser). You need to go to VBA editor screen, choose References... from the Tools menu, find Solver and check the box to allow VBA to use Solver references in your code.

share|improve this answer
add comment

I had the same problem.

I copied my code and created another module. Right clicking Module1 in the Project Tree, I used the "Module1 properties" to change the name of the module to 'Day_Muster' (the name of my sub), but left the name Module1 alone (huh?).

Now when I hit alt-f8 in Outlook, I get the option to run 'Day_Muster'. I click an everything is good!

Hope this helps somebody.

share|improve this answer
1  
Do you know what this does when you do it? –  Raystafarian Mar 7 '12 at 14:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.