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.
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.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With