Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run the macro... the macro may not be available in this workbook

Tags:

excel

vba

I am trying to call a sub on a different worksheet but I got a run time error message.

Specifically, I have two worksheets and multiple VBA sub s in those worksheets. In one of the VBA Project (say workbook1.xlsm), I have the following code:

Sub AnalysisTableMacro() Workbooks("Python solution macro.xlsm").Activate Application.Run "Python solution macro.xlsm!.PreparetheTables" End Sub 

But I got the following error. The macros on both worksheets are enabled. In both worksheets, the subs are in Module1.

Cannot run the macro 'Workbook.xlsm!PrepareTheTables'. The macro may not be available in >this workbook or all macros may be disabled.

I also tried Application.Run "Python solution macro.xlsm!Module1.PreparetheTables" but did not work.

like image 323
Ege Ozlem Avatar asked Aug 22 '13 19:08

Ege Ozlem


People also ask

Why can I not run a macro in Excel?

Step 1: In the File tab, click “options.” Step 2: In the “Excel options” dialog box, click “trust center settings” in the “trust center” option. Step 3: In the “macro settings” option, select “enable all macros.” Click “Ok” to apply the selected macro settings.


1 Answers

If you have a space in the name of the workbook you must use single quotes (') around the file name. I have also removed the full stop.

Application.Run "'Python solution macro.xlsm'!PreparetheTables" 
like image 85
ChipsLetten Avatar answered Sep 22 '22 12:09

ChipsLetten