October 29, 2015

How to Run Macro from Another Workbook

How to run a macro from another workbook with VBA. We can access a macro in a different workbook and use it to perform the tasks for which it was written in the new workbook without having to write the same macro again. The syntax of the macro or VBA code is simple and can also be used to access specific ranges in another workbook. Watch the training video below:


Watch this video on YouTube.

Here’s the VBA code:

Sub runMacro()

Run “‘C:\Users\takyar\etv2\protect-unprotect-worksheet.xlsm’!protectworksheet”

End Sub

The above macro code accesses the following macro in another workbook:

Sub protectworksheet()
Sheets(“Sheet1″).Protect Password:=”asdf,,678”
End Sub

One thought on “How to Run Macro from Another Workbook

  1. Hi Dinesh,

    Hope you are doing good. Thanks for the above program as I was looking for such logic. However, I am facing an issue. I am calling the macro from another workbook using the exact lines of code as presented by you. But I am getting “Runtime error: 9 Subscript Out of Range error” My other macro is not just a Debug Print or Msgbox button. But it actually creates a Named range table and then performs couple of logic. So my question is that does this feature of calling the macro from another workbook, work only for simple Debug Print or Msgbox button etc.

    P.S: My other macro runs absolutely smooth without any issue when I run them separately.


Comments are closed.