MS Excel Error - Cannot run the macro "***". The macros may not be available in this workbook or all macros may be disabled.

Anonymous
2018-02-01T21:13:54+00:00

I have a workbook that I am getting this error in everytime I try and click a button. I have tried creating a new button and I get the same error.

Also, I have another workbook just like this one but for the previous years data and those buttons work perfect. It is the same code and everything. What can I try? Ideas?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

14 answers

Sort by: Most helpful
  1. Anonymous
    2018-02-02T14:37:59+00:00

    Try to recompile the complete VBA project, do as follows:

    Open the VBA editor

    Go into each module

    Insert a line (doesn't matter what you write)

    Press ENTER

    Remove the line that you've inserted

    When finished, in the menu click Debug \ Compile

    It sounds silly to do that, but it's the only way to force the compiler to rebuild any code.

    Andreas.

    Tried that, and hit compile and still is doing it.

    6 people found this answer helpful.
    0 comments No comments
  2. DaveM121 815.8K Reputation points Independent Advisor
    2018-02-02T14:38:18+00:00

    Hi Asnoble,

    Thanks for the screenshot, 2 things to check:

    1.

    Press Alt + F11 to open the VBA Editor

    Does a Macro called CommandButton1_Click exist?

    If not or your Macro has a different name, name it CommandButton1_Click

    Close the VBA Editor

    2.

    Go to File - Options

    Go to Trust Center - Trust Center Settings - Macro Settings

    Set Macro Settings to 'Enable all Macros'

    Save and Exit Options

    Does the Macro then run?

    19 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2018-02-02T14:44:48+00:00

    Hi Asnoble,

    Thanks for the screenshot, 2 things to check:

    1.

    Press Alt + F11 to open the VBA Editor

    Does a Macro called CommandButton1_Click exist?

    If not or your Macro has a different name, name it CommandButton1_Click

    Close the VBA Editor

    2.

    Go to File - Options

    Go to Trust Center - Trust Center Settings - Macro Settings

    Set Macro Settings to 'Enable all Macros'

    Save and Exit Options

    Does the Macro then run?

    Yes, does exists. I have a messagebox behind it for this test.

    Enable All Macros is checked with Radio Button.

    5 people found this answer helpful.
    0 comments No comments
  4. DaveM121 815.8K Reputation points Independent Advisor
    2018-02-02T15:11:52+00:00

    On the same settings page, check the box marked 'Trust access to the VBA project object model'

    Save the settings changes

    Close Excel and start it again, then try running your macro - does it run?

    4 people found this answer helpful.
    0 comments No comments
  5. Anonymous
    2018-02-02T15:36:45+00:00

    On the same settings page, check the box marked 'Trust access to the VBA project object model'

    Save the settings changes

    Close Excel and start it again, then try running your macro - does it run?

    Box is already checked

    9 people found this answer helpful.
    0 comments No comments