Excel macros won't run

I have a large (35 MB) excel model with several dozen macros that I built a few months ago and all the macros ran fine.


Recently I modified the model and changed the names of many of the worksheets.  I edited the macros (renamed them and updated the sheet references).  I also reassigned the newly named macros to the buttons that run them.  However, the macros won't run.  Instead, I get the following error  message:  


"Cannot run the macro "Macro Name".  The macro may not be available or all macros may be disabled."


I have changed the security settings to allow all macros to run and I have also tried recompiling the macros.  Also, when I open the macro and step through it everything seems fine.


Suggestions?

re:  run code

Are the macros in sheet modules?

Sheet modules are private by nature.
If so use the sheet name as a prefix...
  Call Sheet1.myMacro

'---
NLtL

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi Cityzen,

Thank you for querying in this forum.

From your description, it seems that all macros insider a large Excel model worked fine before, however, you encountered an error message after editing the macros. And you have tried changing security setting, however, the same problem still persists. And you also found that it works fine when you open the macro step by step.

If my understanding is right, we have tested it on our side and we cannot reproduce the same situation as yours. Given this situation, you can also refer to the suggestion member provided, at the same time, we’d suggest you create a new simple file with simple Macro, if the new file still has the same problem, we will give you some suggestions below and hope that will help you:

  1. You can open your Excel in safe mode to check if the same problem will occur. It will help in identifying an add-in or extension that may be causing a problem on startup. As steps shown below: Right-click the Start button (lower-left corner) in Windows, and click Run.> In the Run box, type one of the command: excel /safe

  2. At the same time, per our search, someone encountered the same error message and solved the issue via reinstalling, for your reference: Cannot run the macro. “The macro may not be available or all macros may be disabled”, before trying this suggestion, we’d suggest you use Online Repair to fix the Office application. Repair an Office application.

If the same problem still persists after trying the suggestions above, to better understand your situation, could you provide the information below?

  1. Could you provide the Product Information and version of your Excel? You can go to Excel > File > Account and provide the screenshot of it.

  2. May I know if all macros have the same problem? You can create a new file with new simple VBA code to check if the same problem will occur.

  3. Could you provide the screenshot of error message?

Best Regards,

Sukie

• Beware of Scammers posting fake Support Numbers here.
• Please let us know if this is helpful and if the solution worked for you, as it can benefit others who are facing the same scenario.

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi Cityzen,

May I know if you have seen my reply? May I know if you still need help? If so, you can post back and we will try our best to help you.

Best Regards,

Sukie

• Beware of Scammers posting fake Support Numbers here.
• Please let us know if this is helpful and if the solution worked for you, as it can benefit others who are facing the same scenario.

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Sukie,

Thanks for following up. Unfortunately, I am still having the same issue. Below are the steps I've taken:

-I enabled all macros in the Trust Center settings;

-In the original file, a few of the macros work but most do not. I can't see a logic as to which ones work and which ones don't.

-I was able to write a simple macro in a new excel workbook at it worked just fine

- I tried repairing / reinstalling all my office apps and the problem persists with the existing macros.

-I created a test version of the workbook and deleted all the macros and modules. Then I created a new module and pasted several of the macros in - same error message.

Here are the screen shots:

Here is the error message:

Would really appreciate your help. I'm available to do a phone call or an online session.

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi Cityzen,


We appreciate that you posted back and provided so detailed information with us.

We noticed that this issue only occurs when you run specific VBA code, and new simple VBA code works fine. So we assume that this issue may be related to specific VBA code, so to make sure you get professional help, we will help you move this thread to related category, that's specific channel to handle such questions.

Your understanding and patience will be highly appreciated.

Best Regards,

Sukie

• Beware of Scammers posting fake Support Numbers here.
• Please let us know if this is helpful and if the solution worked for you, as it can benefit others who are facing the same scenario.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Ok, please let me know as soon as possible.

Thanks,

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Was able to resolve the problem and the macros now run.

The problem was that the macro names were too long. This occurred because once I created a new workbook with the same macro names, Excel concatenated the workbook name and the macro name. Once I shortened the macro names everything worked fine.

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated May 15, 2024 Views 8,707 Applies to: